# author: Daniel Sommer <daniel.sommer@velvettear.de>
# license: MIT
# variables
swappiness="25"
tmpfs_size="1G"
repository_protocol="https"
# execution
printf"|>> executing alpine install script...\n"
[["$INSTALL_USERNAME"]]&&printf"|> username set to '$INSTALL_USERNAME' via environment variable'...\n"&&user="$INSTALL_USERNAME"
if[[ ! "$user"]];then
read -p "|> enter your desired username: " user
[[ ! "$user"]]&&printf"|> error: no username entered\n"&&exit1
fi
[["$INSTALL_PASSWORD"]]&&printf"|> password set to '$(printf"$INSTALL_PASSWORD\n"| sed "s/./\*/g")' via environment variable'...\n"&&password="$INSTALL_PASSWORD"
if[[ ! "$password"]];then
read -s -p "|> enter the password for '$user': " password &&printf"\n"
[[ ! "$password"]]&&printf"|> error: no password entered\n"&&exit1
read -s -p "|> confirm the password: " password_confirmation &&printf"\n"
[["$password_confirmation" !="$password"]]&&printf"|> error: passwords do not match\n"&&exit1
fi
[["$repository_protocol"]]&&printf"|> setting protocol for all repositories to '$repository_protocol'\n"&& sed -i "s/http/$repository_protocol/g""/etc/apk/repositories"
printf"|> removing motd...\n"
rm -f "/etc/motd"
printf"|> updating packages...\n"
apk update --progress
printf"|> upgrading installed packages...\n"
apk upgrade --progress --no-cache
printf"|> installing base packages...\n"
apk add --force-refresh --no-cache --progress \
sudo \
tzdata \
zsh \
htop \
iotop \
iftop \
neovim \
curl \
wget \
git \
unzip \
rsync \
dropbear \
openssh-client \
rxvt-unicode-terminfo
read -p "|> enter additional packages to install: " packages