#!/bin/bash #================================================= # COMMON VARIABLES #================================================= yunorunner_repository="https://github.com/YunoHost/yunorunner" yunorunner_release="52ef23a2cb37cb4fe13debca58eb589bb2f4d927" #================================================= # PERSONAL HELPERS #================================================= tweak_yunohost() { # Idk why this is needed but wokay I guess >_> echo -e "\n127.0.0.1 $domain #CI_APP" >> /etc/hosts ynh_print_info "Disabling unecessary services to save up RAM..." for SERVICE in mysql php7.4-fpm metronome rspamd dovecot postfix redis-server postsrsd yunohost-api avahi-daemon; do systemctl stop $SERVICE systemctl disable $SERVICE --quiet done yunohost app makedefault -d "$domain" $app } setup_lxd() { if ! yunohost app list --output-as json --quiet | jq -e '.apps[] | select(.id == "lxd")' >/dev/null; then ynh_script_progression --message="Installing LXD... (this make take a long time!" yunohost app install --force https://github.com/YunoHost-Apps/lxd_ynh fi ynh_print_info "Configuring lxd..." if [ "$cluster" -eq 1 ]; then setup_lxd else lxd init --auto # --storage-backend=dir fi # ci_user will be the one launching job, gives it permission to run lxd commands usermod -a -G lxd "$app" ynh_exec_as "$app" lxc remote add yunohost https://devbaseimgs.yunohost.org --public --accept-certificate } exposed_ports_if_cluster() { if [ "$cluster" -eq 1 ]; then echo "8443" fi } setup_lxd_cluster() { local free_space=$(df --output=avail / | sed 1d) local btrfs_size=$(( free_space * 90 / 100 / 1024 / 1024 )) local lxc_network=$((1 + RANDOM % 254)) yunohost firewall allow TCP 8443 tmpfile=$(mktemp --suffix=.preseed.yml) cat >"$tmpfile" < "/var/www/html/maintenance.$app.html" < Your app $app is currently under maintenance!

Your app $app is currently under maintenance!

This app has been put under maintenance by your administrator at $(date)

Please wait until the maintenance operation is done. This page will be reloaded as soon as your app will be back.

EOF # Create a new nginx config file to redirect all access to the app to the maintenance notice instead. cat > "/etc/nginx/conf.d/$domain.d/maintenance.$app.conf" < "/etc/nginx/conf.d/$domain.d/maintenance.$app.conf" systemctl reload nginx # Sleep 4 seconds to let the browser reload the pages and redirect the user to the app. sleep 4 # Then remove the temporary files used for the maintenance. rm "/var/www/html/maintenance.$app.html" rm "/etc/nginx/conf.d/$domain.d/maintenance.$app.conf" systemctl reload nginx }