2015-08-20 14:37:06 -06:00
#!/bin/bash
. ./lib
options=()
if [ -f /usr/bin/yaourt ]; then
options+=("Upgrade with yaourt" "yaourt -Syua")
aurhelper=1
fi
2017-05-07 07:44:41 -06:00
#if [ -f /usr/bin/packer ]; then
# options+=("Upgrade with packer" "packer -Syu")
# aurhelper=1
#fi
2015-08-20 14:37:06 -06:00
if [ ! "$aurhelper" = "1" ]; then
options+=("Install yaourt" "")
2017-05-07 07:44:41 -06:00
# options+=("Install packer" "")
2015-08-20 14:37:06 -06:00
options+=("" "")
fi
options+=("Upgrade" "pacman -Syu")
2016-01-11 13:35:42 -07:00
options+=("Clean orphan" "pacman -Rns \$(pacman -Qqtd)")
2016-01-11 12:14:42 -07:00
options+=("Clean cache" "pacman -Sc")
2015-08-20 14:37:06 -06:00
options+=("" "")
options+=("Edit pacman.conf" "")
options+=("Edit mirrorlist" "")
options+=("" "")
2016-05-14 08:33:14 -06:00
options+=("Refresh pacman keys" "pacman-key --refresh-keys")
options+=("" "")
2015-12-19 12:16:33 -07:00
if [ -f /var/lib/pacman/db.lck ]; then
options+=("Remove db.lck" "rm /var/lib/pacman/db.lck")
options+=("" "")
fi
if [ ! -f /usr/bin/downgrade ]; then
2015-12-19 11:57:14 -07:00
options+=("Install downgrade" "")
fi
2015-08-20 14:37:06 -06:00
if [ "$aurhelper" = "1" ]; then
2017-02-03 11:37:56 -07:00
if [ ! -f /usr/bin/pkgstats ]; then
options+=("Install pkgstats" "")
fi
if [ ! -f /usr/bin/aurvote ]; then
options+=("Install aurvote" "")
fi
2017-02-03 11:40:34 -07:00
if [ ! -f /usr/bin/yaourt ]; then
options+=("Install yaourt" "")
fi
2017-05-07 07:44:41 -06:00
#if [ ! -f /usr/bin/packer ]; then
# options+=("Install packer" "")
#fi
2015-08-20 14:37:06 -06:00
fi
sel=$(whiptail --backtitle "$apptitle" --title "Updates Menu :" --menu "" --cancel-button "Back" 0 0 0 \
"${options[@]}" \
3>&1 1>&2 2>&3)
if [ ! "$?" = "0" ]; then
exit 1
fi
checkaurdependencies(){
if [ ! -f /usr/bin/automake ]; then
pacman -S --needed base-devel
fi
if [ ! $(id -u "aurbuilder") ]; then
newpass=$(< /dev/urandom tr -dc "@#*%&_A-Z-a-z-0-9" | head -c16)
useradd -r -N -M -d /home/.aurbuilder -s /usr/bin/nologin aurbuilder
echo -e "$newpass\n$newpass\n"|passwd aurbuilder
2015-10-13 13:52:44 -06:00
newpass=""
fi
if [ ! -f /etc/sudoers.d/aurbuilder ]; then
2015-10-13 13:48:25 -06:00
echo "aurbuilder ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/aurbuilder
echo "root ALL=(aurbuilder) NOPASSWD: ALL" >> /etc/sudoers.d/aurbuilder
2015-08-20 14:37:06 -06:00
fi
}
checkarchlinuxfrrepo(){
if [ ! $(cat /etc/pacman.conf | grep "archlinuxfr") ]; then
echo "[archlinuxfr]" >> /etc/pacman.conf
echo "SigLevel = Never" >> /etc/pacman.conf
echo 'Server = http://repo.archlinux.fr/$arch' >> /etc/pacman.conf
pacman -Syy
fi
}
2015-08-31 18:49:08 -06:00
clear
2015-08-20 14:37:06 -06:00
case $sel in
'Upgrade') pacman -Syu;;
2015-10-13 13:53:20 -06:00
'Upgrade with yaourt')
checkaurdependencies
sudo -u aurbuilder yaourt -Syua
;;
'Upgrade with packer')
checkaurdependencies
sudo -u aurbuilder packer -Syu
;;
2016-01-11 12:14:42 -07:00
'Clean orphan') pacman -Rns $(pacman -Qqtd);;
'Clean cache') pacman -Sc;;
2015-08-20 14:37:06 -06:00
'Edit pacman.conf') nano /etc/pacman.conf;;
'Edit mirrorlist') nano /etc/pacman.d/mirrorlist;;
2016-05-14 08:33:14 -06:00
'Refresh pacman keys') pacman-key --refresh-keys;;
2015-12-18 14:42:21 -07:00
'Remove db.lck') rm /var/lib/pacman/db.lck;;
2015-12-19 11:57:14 -07:00
'Install downgrade')
checkarchlinuxfrrepo
pacman -S --needed downgrade
;;
2015-08-20 14:37:06 -06:00
'Install yaourt')
if(confirm "Yaourt allow you to access the AUR applications.\nBecause is not possible to compile applications as root,\nthis installer create an aurbuilder user.\n\nInstall yaourt ?") then
2015-08-31 19:26:21 -06:00
clear
2015-08-20 14:37:06 -06:00
checkaurdependencies
checkarchlinuxfrrepo
pacman -S --needed yaourt
fi
;;
'Install packer')
if(confirm "Packer allow you to access the AUR applications.\nBecause is not possible to compile applications as root,\nthis installer create an aurbuilder user.\n\nInstall packer ?") then
2015-08-31 19:26:21 -06:00
clear
2015-08-20 14:37:06 -06:00
checkaurdependencies
checkarchlinuxfrrepo
pacman -S --needed packer
fi
;;
2017-02-03 11:37:56 -07:00
'Install pkgstats')
pacman -S --needed pkgstats
;;
'Install aurvote')
pacman -S --needed aurvote
;;
2015-08-20 14:37:06 -06:00
esac
exit 0