configure-stormux/.includes/convert-to-server.sh

75 lines
2.5 KiB
Bash
Executable File

#!/bin/bash
if [[ "$(whoami)" == "root" ]]; then
dialog --backtitle "Configure Stormux" \
--msgbox "This must be ran without root privileges." -1 -1 --stdout
exit 1
fi
if [[ "$(whoami)" == "stormux" ]]; then
dialog --backtitle "Configure Stormux" \
--msgbox "Default username \"stormux\" and default password \"stormux\" is a huge security risk for a server. Please change your username and password before proceeding." -1 -1 --stdout
exit 1
fi
dialog --backtitle "Configure Stormux" \
--yesno "This will make catastrophic changes to your system. If you are not sure you want to do this, select no by pressing the letter n on your keyboard. Afterwards, you will only be able to login with an ssh key and there will be no screen reader." -1 -1 --stdout || exit 0
dialog --backtitle "Configure Stormux" \
--msgbox "Now let's upload your ssh key. It is a good idea to go ahead and connect via ssh now, in case something goes wrong you will have a chance to fix it manually. This will be used to login to your server, so whatever you do, don't lose it. If you have not yet created an ssh key, you can do so with the ssh-keygen command. Magic-wormhole will be used to upload the key. if you are doing this from a Windows based ssh session, you can install magic-wormhole with scoop: https://github.com/ScoopInstaller/Scoop" -1 -1 --stdout
mkdir -p ~/.ssh
wormhole ssh invite
if ! [[ -e ~/.ssh/authorized_keys ]]; then
exit 1
fi
sudo sed -i 's/^#PasswordAuthentication yes$/PasswordAuthentication no/' /etc/ssh/sshd_config
for i in \
alsa-firmware \
alsa-utils \
bluez \
bluez-utils \
brltty \
cloud-utils \
espeak-ng \
fenrir-git \
growpartfs \
go \
nodm-dgw \
pipewire \
pipewire-alsa \
pipewire-jack \
pipewire-pulse \
poppler \
python-pyudev \
python-daemonize \
python-evdev \
python-dbus \
python-pyte \
rhvoice-voice-bdl \
screen \
sox \
speech-dispatcher \
wireplumber \
xdg-user-dirs \
xdg-utils ; do
yay -Runcds --noconfirm $i
done
rm -rfv ~/.config
rm -rfv ~/Documents
rm -rfv ~/Desktop
rm -rfv ~/Downloads
rm -rfv ~/Music
rm -rfv ~/Pictures
rm -rfv ~/Public
rm -rfv ~/Templates
rm -rfv ~/Videos
sudo rm -rf /opt/configure-stormux
sudo rm -fv /local/bin/configure-stormux
dialog --backtitle "Configure Stormux" \
--msgbox "Hopefully everything went well and your server is ready to go, if not, see you on the other side of the reimage. Reboot for changes to ssh to be applied." -1 -1 --stdout
exit 0