stormux/pi4/files/usr/local/bin/configure-stormux

140 lines
5.1 KiB
Plaintext
Raw Normal View History

#!/usr/bin/env bash
2021-10-24 01:40:14 -04:00
# For audible sudo prompts:
unset sudoFlags
if [[ -x /etc/audibleprompt.sh ]]; then
export SUDO_ASKPASS=/etc/audibleprompt.sh
export sudoFlags=("-A")
fi
trap cleanup EXIT
cleanup() {
popd &> /dev/null
if ! [[ -x /opt/configure-stormux/configure-stormux.sh ]]; then
echo "Initial setup is not complete."
echo "To continue setup, please run:"
echo "sudo configure-stormux"
fi
}
2024-03-05 19:18:01 -05:00
if [[ -x /opt/configure-stormux/configure-stormux.sh ]]; then
pushd /opt/configure-stormux
./configure-stormux.sh
exit 0
fi
export DIALOGOPTS='--insecure --no-lines --visit-items'
set_timezone() {
# Get the list of timezones
mapfile -t regions < <(timedatectl --no-pager list-timezones | cut -d '/' -f1 | sort -u)
# Use the same text twice here and just hide the tag field.
region=$(dialog --backtitle "Please select your Region" \
--no-tags \
--menu "Use up and down arrows or page-up and page-down to navigate the list, and press 'Enter' to make your selection." 0 0 0 \
$(for i in ${regions[@]} ; do echo "$i";echo "$i";done) --stdout)
mapfile -t cities < <(timedatectl --no-pager list-timezones | grep "$region" | cut -d '/' -f2 | sort -u)
# Use the same text twice here and just hide the tag field.
city=$(dialog --backtitle "Please select a city near you" \
--no-tags \
--menu "Use up and down arrow or page-up and page-down to navigate the list." 0 0 10 \
$(for i in ${cities[@]} ; do echo "$i";echo "$i";done) --stdout)
# Set the timezone
if [[ -f /etc/localtime ]]; then
rm /etc/localtime
fi
ln -sf /usr/share/zoneinfo/${region}/${city} /etc/localtime
timedatectl set-ntp true
}
# Offer to switch fenrir layout.
echo "Would you like to switch Fenrir to laptop layout?"
echo "Press y for yes or n for no followed by enter."
read -r continue
continue="${continue::1}"
if [[ "${continue,}" == "y" ]];then
sed -i 's/=desktop/=laptop/' /etc/fenrirscreenreader/settings/settings.conf
clear
systemctl restart fenrirscreenreader.service
fi
# Check for possible resize
diskSource="$(df --output='source' / | tail -1)"
diskSize="$(df -h --output='size' / | tail -1 | tr -cd '[:digit:].')"
diskSize=${diskSize%.*}
2024-11-03 02:18:59 -05:00
if [[ $diskSize -le 7 ]]; then
echo "$diskSource is only $diskSize gigs, which means it probably needs to be resized. Would you like to do this now?"
echo "Press y for yes or n for no followed by enter."
read -r continue
continue="${continue::1}"
if [[ "${continue,}" == "y" ]];then
sudo "${sudoFlags[@]}" growpartfs $diskSource
fi
fi
if ! ping -c1 stormux.org &> /dev/null ; then
echo "No internet connection detected. Press enter to open NetworkManager."
echo "Note, it is best to put Fenrir into highlight mode while using NetworkManager."
echo "In desktop layout this is done by pressing Fenrir+numpad asterisk."
echo "That is the key just above numpad 9."
echo "In laptop mode, press Fenrir+y."
echo "In desktop mode the Fenrir key is numpad insert."
echo "In laptop mode the Fenrir key is the Super key, sometimes called the Windows key."
echo "After connecting to the internet, remember to go back to cursor mode."
echo "It is the same key used to switch to highlight mode."
echo "Press enter to continue."
read -r continue
nmtui-connect
2021-10-24 01:40:14 -04:00
fi
# Check for internet connectivity
if ping -qc1 -W 1 stormux.org &> /dev/null; then
echo "Updating the clock to prevent certificate errors..."
# Get current date and time
date_time=$(curl -s http://worldtimeapi.org/api/ip | grep -oP '(?<="datetime":")[^"]*')
echo "Current date and time: $date_time"
# set date and time
date -s "$date_time"
echo "If your Pi does not have a CMOS battery and is powered off regularly, it may take a while for the time to be set correctly after boot."
echo "Stormux provides a service to sync the time after internet connection is established."
read -rp "Would you like the time to sync as soon as the Pi connects to the internet? " answer
answer="${answer:0:1}"
if [[ "${answer,,}" == "y" ]]; then
systemctl enable time_sync_at_boot.service
else
echo "Time sync at boot skipped."
echo "If you change your mind later, simply type:"
echo "sudo systemctl enable time_sync_at_boot.service"
fi
set_timezone
else
echo "Please connect to the internet and run ${0##*/} again."
exit 1
fi
echo "Installing configure-stormux..."
git -C /opt clone -q https://git.stormux.org/storm/configure-stormux || exit 1
2021-10-24 01:40:14 -04:00
2024-03-03 14:38:44 -05:00
echo
echo "Initial setup is complete."
echo
echo "The default passwords are stormux for the stormux user"
echo "and root for the root user. It is highly recommended to change them."
echo "To change the password for stormux, run:"
echo "passwd"
echo "To change the password for root, run:"
echo "sudo passwd"
echo
echo "For more configuration options, run configure-stormux,"
2024-03-03 14:38:44 -05:00
echo "or you may configure your system manually."
echo
echo "Thank you for choosing Stormux."
2021-10-24 01:40:14 -04:00
exit 0