Skip to content

Commit

Permalink
Made the swapfile dialog and result assignment look more like the oth…
Browse files Browse the repository at this point in the history
…er dialogues

Made the yes/no sequence a bit easier to read

Added comments, clarifying which dialogue needs an
extra-Enter
  • Loading branch information
Marc Richter committed Oct 23, 2023
1 parent 79015a4 commit 144752a
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 25 deletions.
46 changes: 30 additions & 16 deletions scripts/installscripts/buster-install-default.sh
Original file line number Diff line number Diff line change
Expand Up @@ -515,16 +515,30 @@ config_spotify() {
# created for you if needed.
#
"
read -rp "Would you like to have a swapfile created and activated now? [Y/n] " SPOTIcreateswap
read -rp "Would you like to have a swapfile created and activated now? [Y/n] " response
case "${response,,}" in
yes|y)
SPOTIcreateswap=YES
;;
*)
SPOTIcreateswap=NO
;;
esac
if [ "${SPOTIcreateswap}" == "NO" ]; then
echo "You don't want a swapfile to be created."
else
echo "A swapfile will be created and activated for you."
fi
;;
esac

# append variables to config file
{
echo "SPOTinstall=\"$SPOTinstall\"";
echo "SPOTIuser=\"$SPOTIuser\"";
echo "SPOTIpass=\"$SPOTIpass\"";
echo "SPOTIclientid=\"$SPOTIclientid\"";
echo "SPOTIclientsecret=\"$SPOTIclientsecret\""
echo "SPOTIclientsecret=\"$SPOTIclientsecret\"";
echo "SPOTIcreateswap=\"$SPOTIcreateswap\""
} >> "${HOME_DIR}/PhonieboxInstall.conf"
read -rp "Hit ENTER to proceed to the next step." INPUT
Expand Down Expand Up @@ -1306,7 +1320,7 @@ create_swap() {
# If Available memory is less than 2 GB (which is round about what's required during
# gst-plugin-spotify compilation later, ask if another 2 GB swap should be created and
# activated.
local YES_TO_ALL=${1:-false}
local CREATE_SWAPFILE=${1:-NO}

# Install required tools not yet installed
local apt_get="sudo apt-get -qq --yes"
Expand Down Expand Up @@ -1350,21 +1364,21 @@ EOF
EOF
else
if [ ! -f /swapfile ]; then
case "$YES_TO_ALL" in
[nN])
# Do not create swap
echo -e "\nNot creating nor activating swapfile."
echo -e "Your system still lacks available memory though ...\n"
case "${CREATE_SWAPFILE^^}" in
NO)
# Do not create swap
echo -e "\nNot creating nor activating swapfile."
echo -e "Your system still lacks available memory though ...\n"
;;
*)
# Do create swap
echo -e "\nCreating 2 GB swapfile at '/swapfile'. This may take several minutes ...\n"
sudo dd if=/dev/zero of=/swapfile bs=1024k count=2k
sudo chmod 600 /swapfile
sudo mkswap /swapfile
if ! grep -E '^/swapfile' /etc/fstab; then
YES)
# Do create swap
echo -e "\nCreating 2 GB swapfile at '/swapfile'. This may take several minutes ...\n"
sudo dd if=/dev/zero of=/swapfile bs=1024k count=2k
sudo chmod 600 /swapfile
sudo mkswap /swapfile
if ! grep -E '^/swapfile' /etc/fstab; then
echo -e "\n/swapfile\tnone\tswap\tdefaults\t0\t0" | sudo tee -a /etc/fstab >/dev/null
fi
fi
;;
esac
else
Expand Down
37 changes: 28 additions & 9 deletions scripts/installscripts/tests/run_installation_tests3.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,37 @@ echo "samba-common samba-common/dhcp boolean false" | sudo debconf-set-selection
export DEBIAN_FRONTEND=noninteractive

# Run installation (in interactive mode)
# y confirm interactive
# n dont configure wifi
# y Headphone as iface
# y confirm interactive mode
# n dont configure wifi (extra ENTER)
# y Headphone as iface (extra ENTER)
# y spotify with myuser, mypassword, myclient_id, myclient_secret
# y configure mpd
# y audio default location
# y config gpio
# n no RFID registration
# n No reboot
# y swapfile creation (extra ENTER)
# y configure mpd (extra ENTER)
# y audio default location (extra ENTER)
# y config gpio (extra ENTER)
# n start installation

# TODO check, how this behaves on branches other than develop
GIT_BRANCH=develop bash ./scripts/installscripts/buster-install-default.sh <<< $'y\nn\n\ny\n\ny\nmyuser\nmypassword\nmyclient_id\nmyclient_secret\n\ny\n\ny\n\ny\n\ny\nn\nn\n'
GIT_BRANCH=develop bash ./scripts/installscripts/buster-install-default.sh <<< "y
n
y
y
myuser
mypassword
myclient_id
myclient_secret
y
y
y
y
n
n
"

# Test installation
./scripts/installscripts/tests/test_installation.sh

0 comments on commit 144752a

Please sign in to comment.