-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrestore.sh
executable file
·124 lines (103 loc) · 3.33 KB
/
restore.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
#!/bin/bash
set -e
# Set runtime vars
INCLUDE=$(cat include.txt)
SOURCE="${HOME}/tmp_restore"
# Restore from backup file
read -p "- Please enter backup file name: " BACKUP_FILE
if [ ! -f "$BACKUP_FILE" ]; then
echo "ERROR: file not found $BACKUP_FILE"
exit 1
fi
mkdir $SOURCE
echo "Ensuring script dependencies..."
sudo pacman --noconfirm -S unzip zip
echo "Unzipping backup file $BACKUP_FILE"
unzip -d $SOURCE $BACKUP_FILE
# Restore files and folders
echo "Restoring backup of files and folders..."
for path in $INCLUDE
do
if [[ -e "${SOURCE}/${path}" ]]; then
echo "... Restoring file $path"
mv -f $SOURCE/$path $HOME
fi
if [[ -d "${SOURCE}/${path}" ]]; then
echo "... Restoring folder $path"
mv -f $SOURCE/$path $HOME
fi
done
# Import GnuPG keys
echo "Importing gpg keys..."
gpg --import $HOME/tmp_restore/tmp/secret.gpg
gpg --import $HOME/tmp_restore/tmp/secret_sub.gpg
sudo pacman-key --updatedb
gpg --list-key
read -p "- Please enter key ID to update trust: " GPG_KEY_ID
gpg --edit-key $GPG_KEY_ID
# Update system and install required packages
echo "Updating system..."
sudo pacman --noconfirm -Syu
echo "Installing official packages..."
sudo pacman --noconfirm -S base-devel code dbeaver fakeroot docker docker-buildx docker-compose go mousepad nodejs npm obsidian python-pipx python-pytest python-ruff python-uv screen vim yay
read -p "- Install work applications (aws-cli, aws-vault, k9s, kubectl)? [y/N]: " OFFIWORKAPPS
if [ "${OFFIWORKAPPS,,}" = "y" ]; then
sudo pacman --noconfirm -S aws-cli aws-vault k9s kubectl
fi
# Remove unwanted packages
echo "Removing unwanted official packages..."
sudo pacman -R kate || true
sudo pacman -R manjaro-application-utility || true
sudo pacman -R pamac-tray-icon-plasma || true
sudo pacman -R pamac-gtk3 || true
# Install aur packages
echo "Installing aur packages"
mkdir -p $HOME/.ICAClient/cache
yay -S --sudoloop --noconfirm 1password postman-bin pycharm-community-jre sublime-text-4 webstorm webstorm-jre
read -p "- Install work applications from AUR (aws-session-manager-plugin, slack-desktop, teams-for-linux)? [y/N]: " AURWORKAPPS
if [ "${AURWORKAPPS,,}" = "y" ]; then
yay -S --sudoloop --noconfirm aws-session-manager-plugin icaclient slack-desktop teams-for-linux
fi
# Install NVM
echo "Installing nvm..."
git clone https://github.com/nvm-sh/nvm.git $HOME/.nvm
$HOME/.nvm/install.sh
# Add user to docker group
echo "Adding $USER to group 'docker'..."
sudo usermod -aG docker $USER
# Add update checker
# Inspired by: https://www.reddit.com/r/archlinux/comments/1ap45n8/comment/kqdzzk3/
mkdir -p $HOME/.config/systemd/user
cp ./services/* $HOME/.config/systemd/user/
syystemctl --user enable --now checkupdates.timer
# Add loading of .bash_aliases to .bashrc
echo "Updating .bashrc..."
cat <<EOT >> $HOME/.bashrc
if [ -f "${HOME}/.bash_aliases" ]; then
source $HOME/.bash_aliases
fi
export EDITOR=/usr/bin/vim
HISTCONTROL=ignoreboth
HISTSIZE=10000
HISTFILESIZE=10000
EOT
# Disable Baloo
echo "Disabling baloo..."
balooctl6 disable
# Cleanup
echo "Cleaning up..."
rm -rf $HOME/tmp_restore
unset BACKUP_FILE
unset FILES
unset FOLDERS
unset SOURCE
# We're done
echo "Done..."
echo ""
# Last thing we do...
read -p "- Reboot? [y/N]: " REBOOT
if [ "${REBOOT,,}" = "y" ]; then
echo ""
read -p "Save and close any open applications, then press any key..."
reboot
fi