al-skel/upgrade-archlabs

171 lines
4.8 KiB
Plaintext
Raw Normal View History

2017-10-28 23:21:46 -05:00
#!/usr/bin/env bash
#
# A script to upgrade existing installations of ArchLabs
#
# Written by Nathaniel Maia <natemaia10@gmail.com>
#
REPO='
[archlabs_repo]
2017-10-28 23:21:46 -05:00
Server = https://archlabs.github.io/archlabs_repo/$arch
Server = https://downloads.sourceforge.net/project/archlabs-repo/archlabs_repo/$arch'
2017-10-30 07:36:30 -05:00
2017-10-28 23:21:46 -05:00
KEYS=('AEFB411B072836CD48FF0381AE252C284B5DBA5D'
'9E4F11C6A072942A7B3FD3B0B81EB14A09A25EB0'
'35F52A02854DCCAEC9DD5CC410443C7F54B00041')
curWM=$(wmctrl -m | grep Name | cut -d " " -f2)
yes="y"
no="n"
2017-10-28 23:21:46 -05:00
# Loop until network connected
while ! [[ $net >/dev/null ]]; do
net=$(ping -c1 8.8.8.8 2>&1)
echo -e "Please Connect to a Network Before Continuing"
clear; sleep 1
done
2017-10-28 23:21:46 -05:00
setupKeyring() {
clear
echo "############################################################################################
2017-10-28 23:21:46 -05:00
######## Setting up keyring & Adding repo to pacman.conf #########
############################################################################################"
sleep 2
# import each key and populate the keyring
sudo pacman-key --init
sudo pacman-key --populate archlinux
for key in "${KEYS[@]}"; do
if ! sudo pacman-key --list-keys | grep $key > /dev/null 2>&1; then
gpg --receive-keys $key
sudo pacman-key -r $key
fi
done
# add $REPO to pacman.conf
if ! grep "archlabs_repo" /etc/pacman.conf > /dev/null 2>&1; then
echo "$REPO" | sudo tee -a /etc/pacman.conf > /dev/null 2>&1
else # if entries exist remove them
sudo sed -i '/archlabs_repo/d' /etc/pacman.conf
echo "$REPO" | sudo tee -a /etc/pacman.conf > /dev/null 2>&1
fi
# finish populating the keyring
sudo pacman -S archlabs-keyring --needed --noconfirm
sudo pacman-key --populate archlabs
2017-10-28 23:21:46 -05:00
2017-10-28 23:21:46 -05:00
}
backupConfigs() {
clear
echo "############################################################################################
2017-10-28 23:21:46 -05:00
######## Backing up configs to /home/$USER/Downloads/$USER-config-backup.tar.gz #########
############################################################################################"
# Backup configs to $HOME/Downloads/ if backup doesn't exist already
if ! [ -e "$HOME/Downloads/$USER-config-backup.tar.gz" ]; then
tar czvf "$HOME/Downloads/$USER-config-backup.tar.gz" "$HOME"/.{config,Xresources,zshrc,bashrc,icons,xsession,xsessionrc,xinitrc} > /dev/null 2>&1
else
echo "[WARNING] Backup already exists... Not overwriting"
sleep 2
fi
2017-10-28 23:21:46 -05:00
}
2017-10-28 23:21:46 -05:00
setupConfigs() {
clear
echo "############################################################################################
2017-10-28 23:21:46 -05:00
######## Setting up new configs #########
############################################################################################"
sleep 2
# install packages needed for configs
sudo pacman -S clutter-gtk libgee gdk-pixbuf2 pango python-yaml --needed --noconfirm
# cleanup ~/.config
2017-10-30 07:36:30 -05:00
rm -rf "$HOME"/.config/{bspwm,dunst,i3,obmenu-generator,qt5ct,Thunar,conky,geany,neofetch,polybar,termite,xfce4,openbox}
# clean /etc/skel
sudo rm -rf /etc/skel/*
# Copy configs to /etc/skel
2017-10-30 07:36:30 -05:00
sudo cp -rf "$PWD"/home/{bin,.ArchLabs-homepage,.config,.themes,.gorice,.Xresources,.Xresources.template,.mozilla,.zshrc,.bashrc,.icons,.local,.xsession,.xsessionrc,.xinitrc} /etc/skel/
# copy /etc (things like lightdm.conf, oblogout.conf, lsb-release)
sudo cp -rf "$PWD"/etc /
# copy /etc/skel to $HOME
2017-10-30 07:36:30 -05:00
cp -rf /etc/skel/{bin,.ArchLabs-homepage,.config,.themes,.gorice,.Xresources,.Xresources.template,.mozilla,.zshrc,.bashrc,.icons,.local,.xsession,.xsessionrc,.xinitrc} "$HOME"/
2017-10-28 23:21:46 -05:00
}
2017-10-28 23:21:46 -05:00
# first setup Keyring
2017-10-28 23:21:46 -05:00
setupKeyring
# ask to setup configs
clear
printf "\nThis step will get the latest configs for polybar, tint2, openbox, i3, etc.
\n\nYour existing configs will be backed up to an archive located at:
\n\t$HOME/Downloads/$USER-config-backup.tar.gz\n\n\n\nDo you want to continue? [y/N]:"
read -r answer
2017-10-28 23:21:46 -05:00
if [ "${answer,,}" = "${yes,,}" ]; then
2017-10-28 23:21:46 -05:00
# backup configs before continuing
backupConfigs
2017-10-28 23:21:46 -05:00
# setupConfigs only if a backup was made
if [ -e "$HOME/Downloads/$USER-config-backup.tar.gz" ]; then
setupConfigs
fi
# finish up by running setup then reloading everything
$HOME/.config/setup
if [[ $curWM == i3 ]]; then
i3-msg restart
else
$HOME/.config/polybar/scripts/launch-polybar --reload > /dev/null 2>&1
fi
else # only setup skel if answered no
# remove old configs and copy new
sudo rm -rf /etc/skel/*
2017-10-30 07:36:30 -05:00
sudo cp -rf "$PWD"/home/{bin,.ArchLabs-homepage,.config,.themes,.gorice,.Xresources,.Xresources.template,.mozilla,.zshrc,.bashrc,.icons,.local,.xsession,.xsessionrc,.xinitrc} /etc/skel/
sudo cp -rf "$PWD"/etc /
fi
clear
echo "############################################################################################
2017-10-28 23:21:46 -05:00
######## Setup Successfully Completed #########
############################################################################################"
exit 0