yunohost_demo/demo_lxc_build_init.sh

78 lines
1.7 KiB
Bash
Raw Permalink Normal View History

#!/bin/bash
2022-11-06 19:02:46 +01:00
cd "$(dirname $(realpath $0))"
2022-11-06 19:02:46 +01:00
if (( $# < 3 ))
then
cat << EOF
Usage: ./demo_lxc_build_init.sh some.domain.tld SecretAdminPasswurzd! Demo_User Demo_Password
2022-11-06 19:02:46 +01:00
1st and 2nd arguments are for yunohost postinstall
- domain
- admin password
2022-11-06 19:02:46 +01:00
3rd and 4th argument are used for the demo
- demo_user
- demo_password
2022-11-06 19:02:46 +01:00
EOF
exit 1
fi
2022-11-06 19:02:46 +01:00
domain=$1
yuno_pwd=$2
demo_user=$3
demo_password=$4
2022-11-06 19:02:46 +01:00
echo_bold () {
echo -e "\e[1m$1\e[0m"
}
2022-11-06 19:02:46 +01:00
# -----------------------------------------------------------------
2022-11-06 19:02:46 +01:00
function install_dependencies() {
2022-11-06 19:02:46 +01:00
echo_bold "> Installing dependencies..."
apt-get update
apt-get install -y curl wget git python3-pip
}
2022-11-06 19:02:46 +01:00
function setup_yunohost() {
echo_bold "> Setting up Yunohost..."
local DIST="bullseye"
local INSTALL_SCRIPT="https://install.yunohost.org/$DIST"
curl $INSTALL_SCRIPT | bash -s -- -a
echo_bold "> Running yunohost postinstall"
yunohost tools postinstall --domain $domain --password $yuno_pwd
echo_bold "> Disabling unecessary services to save up RAM"
for SERVICE in mysql php7.3-fpm metronome rspamd dovecot postfix redis-server postsrsd yunohost-api avahi-daemon
do
systemctl stop $SERVICE
systemctl disable $SERVICE --quiet
done
}
2022-11-06 19:02:46 +01:00
function setup_yunohost_demo() {
echo_bold "> Installation of yunohost_demo..."
if ! yunohost app list --output-as json --quiet | jq -e '.apps[] | select(.id == "yunohost_demo")' >/dev/null
then
yunohost app install --force https://github.com/YunoHost-Apps/yunohost_demo_ynh -a "domain=$domain&demo_user=$demo_user&demo_password=$demo_password"
fi
}
2022-11-06 19:02:46 +01:00
# =========================
# Main stuff
# =========================
install_dependencies
[ -e /usr/bin/yunohost ] || setup_yunohost
2022-11-06 19:02:46 +01:00
setup_yunohost_demo
2022-11-06 19:02:46 +01:00
echo "Done!"
echo " "