Chris Druif
2 years ago
1 changed files with 87 additions and 41 deletions
@ -1,48 +1,94 @@
|
||||
#! /bin/bash |
||||
|
||||
#dialog that explains what will happen & create $USER, with option to cancel |
||||
#dialog installer that explains what will happen & create $USER, with option to cancel |
||||
|
||||
TITLE="Pyrenee Conversion Utility" |
||||
dialog --colors --backtitle "\Z7$TITLE" --title "WELCOME!" --yes-label "OK" --msgbox "Welcome to the Pyrenee Conversion Utility.\n\nThis utility will make a number of (mostly reversible) changes to your system. It should be run directly after installing Alpine Linux, which will setup the foundation we build upon." 10 50 |
||||
dialog --colors --backtitle "\Z7$TITLE" --form "Please supply the required information:\n(username can only contain small letters)" 10 50 3 "Full Name:" 1 0 "" 1 10 15 0 "Username:" 2 0 "" 2 10 15 0 2>input && FULLNAME=$(sed -n '1p' input) && USER=$(sed -n '2p' input | sed 's/[A-Z]/\L&/g') && rm -f input |
||||
dialog --colors --insecure --backtitle "\Z7$TITLE" --title "Password Provider" --passwordbox "Provide a password for $FULLNAME" 10 50 2>password && PASSWORD=$(sed -n '1p' password) && rm -f password |
||||
dialog --colors --backtitle "\Z7$TITLE" --title "Confirmation" --yes-label "Enter" --no-label "Esc" --yesno "Please press <Enter> to start conversion or <Esc> to cancel." 10 50 |
||||
#some constant values used by the dialog screens to make them more legible |
||||
BACK="--colors --backtitle" |
||||
TITLE="\Z7Pyrenee Conversion Utility" |
||||
MSG=--msgbox --yes-label "OK" |
||||
SIZE="10 50" |
||||
|
||||
# Return status of non-zero indicates cancel |
||||
if [ "$?" != "0" ] |
||||
then |
||||
dialog --colors --backtitle "\Z7$TITLE" --msgbox "Pyrenee Conversion was canceled at your request." 10 50 |
||||
else |
||||
adduser -D -g "$FULLNAME" $USER |
||||
echo -e "$PASSWORD\n$PASSWORD" | passwd $USER |
||||
|
||||
cp /etc/apk/repositories /etc/apk/repositories.bak |
||||
sed -i s/http/https /etc/apk/repositories |
||||
|
||||
cp /etc/default/useradd /etc/default/useradd.bak |
||||
sed -i s/ash/bash /etc/default/useradd |
||||
echo -e '#! /bin/bash\n\nalias sudo="doas"\nalias rm="rm -i"' > /etc/profile.d/aliases.sh |
||||
|
||||
apk upgrade --available |
||||
setup-xorg-base |
||||
apk add doas htop nano falkon flatpak plasma kde-applications-base kde-applications-accessibility pm-utils |
||||
echo -e "#!/bin/sh\n\nexec pm-suspend" >> /etc/acpi/LID/00000080 |
||||
chmod +x /etc/acpi/LID/00000080 |
||||
|
||||
cp /etc/doas.d/doas.conf /etc/doas.d/doas.conf.bak |
||||
echo -e "permit :wheel\npermit persist :wheel" >> /etc/doas.d/doas.conf |
||||
rc-update add sddm |
||||
#rc-service sddm start |
||||
|
||||
adduser $USER wheel |
||||
su $USER |
||||
flatpak --user remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo |
||||
flatpak install flatseal |
||||
fi |
||||
dialog --colors --backtitle "\Z7$TITLE" --title "Finished!" --yes-label "Enter" --no-label "Esc" --yesno "Conversion was completed, it is recommended to reboot to enter your new Desktop experience!\n\nPlease press <Enter> to reboot or <Esc> to continue your current session." 10 50 |
||||
if [ "$?" != "0" ] |
||||
dialog $BACK "$TITLE" --title "WELCOME!" $MSG "Welcome to the Pyrenee Conversion Utility.\n\nThis utility will make a number of (mostly reversible) changes to your system. It should be run directly after installing Alpine Linux 3.15, which will setup the foundation we build upon." $SIZE |
||||
|
||||
dialog $BACK "$TITLE" --form "Please supply the required information:\n(username can only contain small letters)" 10 50 3 "Full Name:" 1 0 "" 1 10 15 0 "Username:" 2 0 "" 2 10 15 0 2>input && FULLNAME=$(sed -n '1p' input) && USER=$(sed -n '2p' input | sed 's/[A-Z]/\L&/g') && rm -f input |
||||
|
||||
dialog $BACK "$TITLE" --insecure --title "Password Provider" --passwordbox "Provide a password for $FULLNAME" $SIZE 2>password && PASSWORD1=$(sed -n '1p' password) && rm -f password |
||||
|
||||
dialog $BACK "$TITLE" --insecure --title "Password Provider" --passwordbox "Confirm password for $FULLNAME" $SIZE 2>password && PASSWORD2=$(sed -n '1p' password) && rm -f password |
||||
|
||||
if [ "$PASSWORD1" != "$PASSWORD2" ] || [ "$PASSWORD1" = "" ] || [ "$PASSWORD2" = "" ] || [ "$USER" = "" ] || [ "$FULLNAME" = "" ] |
||||
then |
||||
clear |
||||
dialog $BACK "$TITLE" $MSG "Pyrenee Conversion was canceled because the provided passwords didn't match or any necessary input was omitted.\n\nPlease restart the Pyrenee Conversion Utility." $SIZE && clear |
||||
else |
||||
doas reboot now |
||||
dialog $BACK "$TITLE" --title "Confirmation" --yes-label "Enter" --no-label "Esc" --yesno "This is the last opportunity to cancel the conversion.\n\nPlease press <Enter> to start conversion or <Esc> to cancel." $SIZE |
||||
|
||||
#Return status of non-zero indicates cancel |
||||
if [ "$?" != "0" ] |
||||
then |
||||
dialog $BACK "$TITLE" $MSG "Pyrenee Conversion was canceled at your request." $SIZE && clear |
||||
else |
||||
adduser -D -g "$FULLNAME" $USER |
||||
echo -e "$PASSWORD1\n$PASSWORD2" | passwd $USER |
||||
adduser $USER wheel |
||||
|
||||
#backup rc.conf & enable rc_parallel |
||||
cp /etc/rc.conf /etc/rc.conf.bak |
||||
sed -i s/\#rc\_parallel\=\"NO\"/rc\_parallel\=\"YES\"/g /etc/rc.conf |
||||
|
||||
#backup & switch repositories config file to https connection |
||||
cp /etc/apk/repositories /etc/apk/repositories.bak |
||||
sed -i s/http/https /etc/apk/repositories |
||||
sed -i 's/\# //g' /etc/apk/repositories |
||||
|
||||
#backup original useradd config file & switch default shell from ash to bash. |
||||
cp /etc/default/useradd /etc/default/useradd.bak |
||||
sed -i s/ash/bash /etc/default/useradd |
||||
#add aliases to bash to ease transition to doas & make 'rm' always interactive. |
||||
echo -e '#! /bin/bash\n\nalias sudo="doas"\nalias rm="rm -i"' > /etc/profile.d/aliases.sh |
||||
|
||||
apk upgrade |
||||
setup-xorg-base |
||||
apk add doas htop nano falkon flatpak plasma kde-applications-base kde-applications-accessibility pm-utils | dialog $BACK "$TITLE" --progressbox $SIZE |
||||
|
||||
<<COMMENT |
||||
#enable Internet Wireless Device (iwd) |
||||
apk add iwd |
||||
rc-service iwd start |
||||
cp /etc/NetworkManager/NetworkManager.conf /etc/NetworkManager/NetworkManager.conf.bak |
||||
echo -e "\n[device]\nwifi.backend=iwd" >> /etc/NetworkManager/NetworkManager.conf |
||||
COMMENT |
||||
|
||||
#enable Suspend on LID close |
||||
cat > /etc/acpi/LID/00000080 <<< "#!/bin/sh\n\nexec pm-suspend" |
||||
chmod +x /etc/acpi/LID/00000080 |
||||
|
||||
<<COMMENT |
||||
#add pipewire and its plumbing |
||||
#https://wiki.alpinelinux.org/wiki/PipeWire |
||||
apk add pipewire wireplumber pipewire-pulse pipewire-jack pipewire-spa-bluez |
||||
mkdir /etc/pipewire |
||||
cp /usr/share/pipewire/pipewire.conf /etc/pipewire/ |
||||
echo '{ path = "wireplumber" args = "" }' >> /etc/pipewire/pipewire.conf |
||||
modprobe snd_seq |
||||
echo snd_seq >> /etc/modules |
||||
COMMENT |
||||
|
||||
#backup original doas.conf and permit group wheel and add some persistence |
||||
cp /etc/doas.d/doas.conf /etc/doas.d/doas.conf.bak |
||||
echo -e "permit :wheel\npermit persist :wheel" >> /etc/doas.d/doas.conf |
||||
#add sddm to OpenRC to automatically start it at boot |
||||
rc-update add sddm |
||||
|
||||
#switch to user and add Flathub to Flatpak and install Flatseal to graphically edit permissions |
||||
su $USER |
||||
flatpak --user remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo |
||||
flatpak install flatseal |
||||
dialog $BACK "$TITLE" --title "Finished!" --yes-label "Enter" --no-label "Esc" --yesno "Conversion was completed, it is recommended to reboot to finish your new Desktop experience!\n\nPlease press <Enter> to reboot or <Esc> to continue your current session." $SIZE |
||||
if [ "$?" != "0" ] |
||||
then |
||||
clear |
||||
else |
||||
doas reboot now |
||||
fi |
||||
fi |
||||
fi |
||||
|
Loading…
Reference in new issue