mirror of
https://github.com/YunoHost-Apps/octoprint_ynh.git
synced 2024-09-03 19:46:26 +02:00
66 lines
2.1 KiB
Bash
66 lines
2.1 KiB
Bash
#!/bin/bash
|
|
# to test the functionnality :
|
|
# yunohost backup create -n "octoprint-test" --apps octoprint
|
|
# yunohost app remove octoprint
|
|
# yunohost backup restore "octoprint-test"
|
|
|
|
source ../settings/scripts/_common.sh
|
|
source /usr/share/yunohost/helpers
|
|
|
|
# manage script failure
|
|
#REMOVEME? ynh_abort_if_errors
|
|
|
|
# retrieve arguments
|
|
#REMOVEME? app=$YNH_APP_INSTANCE_NAME
|
|
#REMOVEME? domain=$(ynh_app_setting_get "$app" domain)
|
|
#REMOVEME? port=$(ynh_app_setting_get "$app" port)
|
|
|
|
# definie useful vars
|
|
#REMOVEME? install_dir="/opt/yunohost/$app"
|
|
home_path="/home/$app"
|
|
data_path="/home/$app/.$app"
|
|
|
|
# check domain/path availability
|
|
path=$(ynh_normalize_url_path "/")
|
|
#REMOVEME? ynh_webpath_available $domain $path || ynh_die "$domain/$path is not available, please use an other domain."
|
|
|
|
# add required packages
|
|
#REMOVEME? ynh_install_app_dependencies "$PKG_DEPENDENCIES"
|
|
|
|
# restore dedicated system user
|
|
ynh_system_user_exists "$app" && ynh_die "User $app is not available"
|
|
#REMOVEME? ynh_system_user_create "$app"
|
|
|
|
# restore conf files
|
|
ynh_restore_file "/etc/nginx/conf.d/$domain.d/$app.conf"
|
|
ynh_restore_file "/etc/sudoers.d/$app"
|
|
ynh_restore_file "/etc/systemd/system/$app@$app.service"
|
|
|
|
# restore source
|
|
if [ ! -d "$install_dir" ]; then
|
|
ynh_restore_file "$install_dir"
|
|
else
|
|
ynh_die "There is already a directory: $install_dir"
|
|
fi
|
|
|
|
# restore data
|
|
if [ ! -d "$home_path" ]; then
|
|
ynh_restore_file "$home_path"
|
|
chown -R $app: "$home_path"
|
|
else
|
|
ynh_die "$home_path already exists and will not be overwritten"
|
|
fi
|
|
|
|
# restore port
|
|
#REMOVEME? [ $port -eq $(ynh_find_port $port) ] || ynh_die "$port is not available, please use an other port"
|
|
ynh_exec_fully_quiet yunohost firewall allow TCP $port
|
|
|
|
# add service in admin panel
|
|
yunohost service add "$app@$app" --log "$data_path/octoprint.log" --description "Octoprint server"
|
|
|
|
# enable & restart systemd service
|
|
ynh_system_reload --service_name="$app@$app" --action=enable
|
|
ynh_check_starting --line_to_match="Octoprint initialized" --app_log="systemd" --timeout=1000 --service_name="$app@$app"
|
|
|
|
# reload nginx
|
|
ynh_system_reload --service_name=nginx
|