added update functionality to the fresh script + packs added

master
toerd 6 years ago
parent e35a11a1e3
commit b9623862a4

@ -1,13 +1,12 @@
#!/bin/bash #!/bin/bash
# TODO: count of packages depending on selected platform
# TODO: function to place udev rules
scriptdir=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) scriptdir=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
logfile="/dev/null" logfile="/dev/null"
todo="install"
# Get params # Get params
while getopts "r:p:d:vh" opt; while getopts "r:p:d:vuh" opt;
do case $opt in do case $opt in
h) echo -e "-r: https://link-to-repo\n-p: /link/to/prog/file\n-d: devicename for special dotfiles\n-v: verbose, please supply logfile path (default is $HOME/install.log)" && exit ;; h) echo -e "-r: https://link-to-repo\n-p: /link/to/prog/file\n-d: devicename for special dotfiles\n-v: verbose, please supply logfile path (default is $HOME/install.log)" && exit ;;
d) device=${OPTARG} ;; d) device=${OPTARG} ;;
@ -15,6 +14,7 @@ do case $opt in
p) prog=${OPTARG} ;; p) prog=${OPTARG} ;;
a) aurhelper=${OPTARG} ;; a) aurhelper=${OPTARG} ;;
v) logfile="$scriptdir/install.log" ;; v) logfile="$scriptdir/install.log" ;;
u) todo="update" ;;
\?) echo "-$OPTARG is not valid" >&2 && exit ;; \?) echo "-$OPTARG is not valid" >&2 && exit ;;
esac esac
done done
@ -26,14 +26,18 @@ aurhelper=${aurhelper:="yay"}
startup_msg() { startup_msg() {
curr_platform=$(dialog --clear --title "Welcome to the installer <3" --menu "Choose your current platform:" 0 0 2 "L" "Laptop" "D" "Desktop" 2>&1>/dev/tty) curr_platform=$(dialog --clear --title "Welcome to the Freshcript <3" --menu "Choose your current platform:" 0 0 2 "L" "Laptop" "D" "Desktop" 2>&1>/dev/tty)
echo "Installation started - Platform is: $curr_platform\n\n" >> $logfile echo "Script started - Platform is: $curr_platform\n\n" >> $logfile
} }
init() { init() {
pacman -S --noconfirm --needed dialog git make || { echo "Run as root user"; exit; } pacman -S --noconfirm --needed dialog git make || { echo "Run as root user"; exit; }
dialog --infobox "Refresh of the Keyring" 0 0 refresh_keyring
}
refresh_keyring() {
pacman --noconfirm -Sy archlinux-keyring &>> $logfile pacman --noconfirm -Sy archlinux-keyring &>> $logfile
dialog --infobox "Refresh of the Keyring" 0 0
} }
pre_install() { pre_install() {
@ -41,6 +45,12 @@ pre_install() {
echo "Automatic part started\n\n" >> $logfile echo "Automatic part started\n\n" >> $logfile
} }
pre_update() {
uname=$(logname)
dialog --title "Start the Update" --yes-label "Okey Dokey Artischokey" --no-label "NOPE Byeee" --yesno "\nUpdateriniho as user > $uname <" 0 0 || { clear; exit; }
echo "Automatic update started as user:$uname\n\n" >> $logfile
}
get_credentials() { get_credentials() {
uname=$(dialog --inputbox "Enter an username" 0 0 2>&1 1>/dev/tty) uname=$(dialog --inputbox "Enter an username" 0 0 2>&1 1>/dev/tty)
echo $uname echo $uname
@ -84,7 +94,7 @@ install_manual() {
msd=$((msd+1)) msd=$((msd+1))
dialog --title "Manual packages" --infobox "Manual Package $msd/$ms\n\nInstalling: $1\n\n> $2 <" 0 0 dialog --title "Manual packages" --infobox "Manual Package $msd/$ms\n\nInstalling: $1\n\n> $2 <" 0 0
cd "$scriptdir/packages/$1" || exit cd "$scriptdir/packages/$1" || exit
make clean && make && make install &>> $logfile ; make clean && make && make install && make clean&>> $logfile ;
cd "/home/$uname" || exit cd "/home/$uname" || exit
} }
@ -100,9 +110,10 @@ install_aur_helper() {
installation_loop() { installation_loop() {
echo "Entered installationloop\n\n" >> $logfile echo "Entered installationloop\n\n" >> $logfile
([ -f "$prog" ] && cp "$prog" /tmp/pack.csv) || curl -Ls "$prog" > /tmp/pack.csv ([ -f "$prog" ] && cp "$prog" /tmp/pack.csv) || curl -Ls "$prog" > /tmp/pack.csv
ps=$(grep -e ",P," /tmp/pack.csv | wc -l) # count packages and sum results for all and curr platform
as=$(grep -e ",A," /tmp/pack.csv | wc -l) ps=$(($(grep -e "A,P," /tmp/pack.csv | wc -l) + $(grep -e "$curr_platform,P," /tmp/pack.csv | wc -l)))
ms=$(grep -e ",M," /tmp/pack.csv | wc -l) as=$(($(grep -e "A,A," /tmp/pack.csv | wc -l) + $(grep -e "$curr_platform,A," /tmp/pack.csv | wc -l)))
ms=$(($(grep -e "A,M," /tmp/pack.csv | wc -l) + $(grep -e "$curr_platform,M," /tmp/pack.csv | wc -l)))
aur_already_installed=$(pacman -Qqm) aur_already_installed=$(pacman -Qqm)
#IFS separator #IFS separator
while IFS=, read -r platform prefix program info; do while IFS=, read -r platform prefix program info; do
@ -193,17 +204,32 @@ set_system_stuff() {
} }
# ACTUAL ROUTINE # ACTUAL ROUTINE
init case $todo in
startup_msg install)
get_credentials init
pre_install startup_msg
create_user get_credentials
set_permissions "%wheel ALL=(ALL) NOPASSWD: ALL" pre_install
install_aur_helper create_user
installation_loop set_permissions "%wheel ALL=(ALL) NOPASSWD: ALL"
download_dotfiles install_aur_helper
set_permissions "%wheel ALL=(ALL) ALL\\n%wheel ALL=(ALL) NOPASSWD: /usr/bin/shutdown,/usr/bin/reboot,/usr/bin/systemctl suspend,/usr/bin/wifi-menu,/usr/bin/mount,/usr/bin/umount,/usr/bin/pacman -Syu,/usr/bin/pacman -Syyu,/usr/bin/packer -Syu,/usr/bin/packer -Syyu,/usr/bin/systemctl restart NetworkManager,/usr/bin/rc-service NetworkManager restart,/usr/bin/pacman -Syyu --noconfirm,/usr/bin/loadkeys,/usr/bin/yay" installation_loop
no_beep download_dotfiles
set_system_stuff set_permissions "%wheel ALL=(ALL) ALL\\n%wheel ALL=(ALL) NOPASSWD: /usr/bin/shutdown,/usr/bin/reboot,/usr/bin/systemctl suspend,/usr/bin/wifi-menu,/usr/bin/mount,/usr/bin/umount,/usr/bin/pacman -Syu,/usr/bin/pacman -Syyu,/usr/bin/packer -Syu,/usr/bin/packer -Syyu,/usr/bin/systemctl restart NetworkManager,/usr/bin/rc-service NetworkManager restart,/usr/bin/pacman -Syyu --noconfirm,/usr/bin/loadkeys,/usr/bin/yay"
ready_steady_go no_beep
clear set_system_stuff
enable_service "--user syncthing" "netctl-auto@wlp3s0"
ready_steady_go
clear
;;
update)
init
startup_msg
refresh_keyring
pre_update
installation_loop
set_system_stuff
ready_steady_go
clear
;;
esac

@ -13,7 +13,6 @@ A,P,xfsprogs,XFS filesystem utilities
A,P,intel-ucode,Microcode update files for Intel CPUs A,P,intel-ucode,Microcode update files for Intel CPUs
L,P,acpi,Client for battery power and thermal readings L,P,acpi,Client for battery power and thermal readings
L,P,acpid,A daemon for delivering ACPI power management events with netlink support L,P,acpid,A daemon for delivering ACPI power management events with netlink support
A,P,pulseaudio,A featureful general-purpose sound server
A,P,openssh,ssh A,P,openssh,ssh
# Package management # Package management

1 # First column: A = All, L = Laptop, D = Desktop
13 L,P,acpi,Client for battery power and thermal readings
14 L,P,acpid,A daemon for delivering ACPI power management events with netlink support
15 A,P,pulseaudio,A featureful general-purpose sound server A,P,openssh,ssh
A,P,openssh,ssh
16 # Package management
17 A,P,reflector,sort mirrorlist
18 # Fonts
Loading…
Cancel
Save