119 lines
3.7 KiB
Bash
Executable File
119 lines
3.7 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
#
|
|
# A script to upgrade existing installations of ArchLabs
|
|
#
|
|
# Written by Nathaniel Maia <natemaia10@gmail.com>
|
|
#
|
|
|
|
REPOS='
|
|
[archlabs_repo]
|
|
Server = https://archlabs.github.io/archlabs_repo/$arch
|
|
Server = https://downloads.sourceforge.net/project/archlabs-repo/archlabs_repo/$arch'
|
|
|
|
HOME_FILES=("$HOME/bin" "$HOME/.config" "$HOME/.themes"
|
|
"$HOME/.gorice" "$HOME/.Xresources" "$HOME/.Xresources.template"
|
|
"$HOME/.mozilla" "$HOME/.zshrc" "$HOME/.bashrc"
|
|
"$HOME/.local" "$HOME/.xprofile" "$HOME/.xinitrc"
|
|
"$HOME/.icons" "$HOME/.gtkrc-2.0"
|
|
)
|
|
|
|
SKEL_FILES=('/etc/skel/bin' '/etc/skel/.config' '/etc/skel/.themes'
|
|
'/etc/skel/.Xresources' '/etc/skel/.gorice' '/etc/skel/.icons'
|
|
'/etc/skel/.gtkrc-2.0' '/etc/skel/.xprofile' '/etc/skel/.xinitrc'
|
|
'/etc/skel/.mozilla' '/etc/skel/.Xresources.template'
|
|
)
|
|
|
|
WMS=(i3 openbox)
|
|
for i in "${WMS[@]}"; do
|
|
if [[ "$(wmctrl -m | grep -i name | awk '{print tolower($2)}')" == "$i" ]]; then
|
|
WM=$i && break
|
|
elif [[ "$(xprop -root -notype | grep "WM_NAME =" | tr -d '"' | awk '{print tolower($3)}')" == "$i" ]]; then
|
|
WM=$i && break
|
|
elif [[ "$(awk '{print tolower($0)}' <<< "$XDG_CURRENT_DESKTOP")" == "$i" ]]; then
|
|
WM=$i && break
|
|
fi
|
|
done
|
|
|
|
# Loop until network connected
|
|
while ! [[ $(ping -c1 8.8.8.8) ]]; do
|
|
echo -e "Please Connect to a Network Before Continuing"
|
|
clear; sleep 1
|
|
done
|
|
|
|
setup_keyring() {
|
|
KEYS=('AEFB411B072836CD48FF0381AE252C284B5DBA5D'
|
|
'9E4F11C6A072942A7B3FD3B0B81EB14A09A25EB0'
|
|
'35F52A02854DCCAEC9DD5CC410443C7F54B00041'
|
|
)
|
|
sudo dirmngr </dev/null
|
|
sudo pacman-key --init
|
|
sudo pacman-key --populate archlinux
|
|
for key in "${KEYS[@]}"; do
|
|
if ! grep -q "$key" <<< "$(sudo pacman-key --list-keys)"; then
|
|
gpg --receive-keys "$key"
|
|
sudo pacman-key -r "$key"
|
|
fi
|
|
done
|
|
sudo pacman -S archlabs-keyring --needed --noconfirm
|
|
sudo pacman-key --populate archlabs
|
|
|
|
if grep -q "archlabs_repo" /etc/pacman.conf; then
|
|
sudo sed -i '/archlabs_repo/d' /etc/pacman.conf
|
|
fi
|
|
echo "$REPOS" | sudo tee -a /etc/pacman.conf >/dev/null 2>&1
|
|
}
|
|
|
|
backup_configs() {
|
|
if ! [[ -e "$HOME/Downloads/$USER-backup.tar.gz" ]]; then
|
|
tar czvf "$HOME/Downloads/$USER-backup.tar.gz" "${HOME_FILES[@]}" >/dev/null 2>&1
|
|
else
|
|
echo "[WARNING] Backup already exists... Not overwriting"
|
|
sleep 2
|
|
fi
|
|
}
|
|
|
|
setup_configs() {
|
|
sudo pacman -S clutter-gtk libgee archlabs-jgmenu --needed --noconfirm
|
|
sudo pacman -S gdk-pixbuf2 pango python-yaml --needed --noconfirm
|
|
cp -rf "${SKEL_FILES[@]}" "$HOME/"
|
|
cp -f /etc/skel/.{bashrc,zshrc} "$HOME/"
|
|
}
|
|
|
|
new_configs() {
|
|
clear
|
|
printf "\nThis step will get the latest configs for polybar, openbox, i3 etc.
|
|
\n\nYour existing configs will be archived to:
|
|
\n\t$HOME/Downloads/$USER-backup.tar.gz\n\n\n\nDo you want to continue? [y/N]:"
|
|
read -r answer
|
|
|
|
case "$answer" in
|
|
y|yes|Y|YES)
|
|
backup_configs
|
|
if [[ -e $HOME/Downloads/$USER-backup.tar.gz ]]; then
|
|
setup_configs
|
|
fi
|
|
rm -f "$HOME/.config/keypack"
|
|
sed -i '/keypack/d' "$HOME/.config/openbox/autostart"
|
|
~/.config/setup
|
|
esac
|
|
}
|
|
|
|
|
|
setupKeyring
|
|
if ! pacman -Q archlabs-user-skel >/dev/null 2>&1; then
|
|
sudo rm -rf "${SKEL_FILES[@]}"
|
|
sudo pacman -S archlabs-user-skel --needed --noconfirm
|
|
else
|
|
sudo pacman -Syyu --noconfirm
|
|
fi
|
|
|
|
new_configs
|
|
|
|
clear
|
|
echo "##########################################################
|
|
######## Setup Completed #########
|
|
##########################################################"
|
|
|
|
exit 0
|