#!/bin/bash #================================================= # COMMON VARIABLES #================================================= yunorunner_repository="https://github.com/YunoHost/yunorunner" yunorunner_release="a2ab9f576b2ab628190aa65d48dcdad727a81929" #================================================= # 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_incus() { ynh_print_info "Configuring Incus..." # ci_user will be the one launching job, gives it permission to run incus commands usermod -a -G incus-admin "$app" if [ "$cluster" -eq 1 ]; then yunohost firewall allow TCP 8443 free_space=$(df --output=avail / | sed 1d) btrfs_size=$(( free_space * 90 / 100 / 1024 / 1024 )) incus_network=$((1 + RANDOM % 254)) ynh_add_config --template="incus-preseed.yml" --destination="$install_dir/incus-preseed.yml" incus admin init --preseed < "$install_dir/incus-preseed.yml" rm "$install_dir/incus-preseed.yml" incus config set core.https_address "[::]" else incus admin init --auto # --storage-backend=dir fi ynh_exec_as "$app" incus remote add yunohost https://devbaseimgs.yunohost.org --public --accept-certificate } exposed_ports_if_cluster() { if [ "$cluster" -eq 1 ]; then echo "--needs_exposed_ports=8443" fi } _ynh_firewall_add_tweak() { mkdir -p "/etc/yunohost/hooks.d/post_iptable_rules" ynh_add_config --template="firewall_rules.sh" --destination="/etc/yunohost/hooks.d/post_iptable_rules/50-${app}" yunohost firewall reload } _ynh_firewall_remove_tweak() { ynh_secure_remove --file="/etc/yunohost/hooks.d/post_iptable_rules/50-${app}" yunohost firewall git remote add origin git@github.com:user/repository.git } #================================================= # EXPERIMENTAL HELPERS #================================================= #================================================= # FUTURE OFFICIAL HELPERS #================================================= ynh_maintenance_mode_ON () { # Create an html to serve as maintenance notice cat > "/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 }