diff --git a/scripts/install b/scripts/install index 8822a73..953f7eb 100644 --- a/scripts/install +++ b/scripts/install @@ -69,6 +69,17 @@ ynh_script_progression --message="Configuring NGINX web server..." # Create a dedicated NGINX config ynh_add_nginx_config +# Create a dedicated systemd config +ynh_add_systemd_config + +mkdir -p "/var/log/$app" +chown -R $app:$app "/var/log/$app" + +# Use logrotate to manage application logfile(s) +ynh_use_logrotate + +yunohost service add $app --description="$app daemon for Peertube" --log="/var/log/$app/$app.log" --needs_exposed_ports $port_rtmp + #================================================= # BUILD YARN DEPENDENCIES #================================================= @@ -95,76 +106,17 @@ ynh_add_config --template="../conf/local-production.json" --destination="$instal chmod 600 "$install_dir/config/local-production.json" chown $app:$app "$install_dir/config/local-production.json" -#================================================= -# SETUP SYSTEMD -#================================================= -ynh_script_progression --message="Configuring a systemd service..." - -# Create a dedicated systemd config -ynh_add_systemd_config - -#================================================= -# START SYSTEMD SERVICE -#================================================= -ynh_script_progression --message="Starting a systemd service..." - -mkdir -p "/var/log/$app" -chown -R $app:$app "/var/log/$app" -# Start a systemd service -ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="Started" - #================================================= # INSTALL LDAP PLUGIN #================================================= -ynh_script_progression --message="Installing LDAP plugin..." +ynh_script_progression --message="Installing $app plugin and password..." pushd "$install_dir" ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH NODE_CONFIG_DIR="$install_dir/config" NODE_ENV=production $ynh_npm run plugin:install -- --npm-name peertube-plugin-auth-ldap -popd - -#================================================= -# INSTALL PEERTUBE LIVECHAT PLUGIN -#================================================= -ynh_script_progression --message="Installing PeerTube livechat plugin..." - -pushd "$install_dir" ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH NODE_CONFIG_DIR="$install_dir/config" NODE_ENV=production $ynh_npm run plugin:install -- --npm-name peertube-plugin-livechat -popd - -#================================================= -# CHANGE PEERTUBE ADMIN PASSWORD -#================================================= -ynh_script_progression --message="Changing PeerTube admin password..." - -pushd "$install_dir" echo $admin_pass | ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH NODE_CONFIG_DIR="$install_dir/config" NODE_ENV=production $ynh_npm run reset-password -- -u root popd -#================================================= -# STOP SYSTEMD SERVICE -#================================================= -ynh_script_progression --message="Stopping a systemd service..." - -# Stop a systemd service -ynh_systemd_action --service_name=$app --action="stop" --log_path="systemd" --line_match="Stopped" - -#================================================= -# GENERIC FINALIZATION -#================================================= -# SETUP LOGROTATE -#================================================= -ynh_script_progression --message="Configuring log rotation..." - -# Use logrotate to manage application logfile(s) -ynh_use_logrotate - -#================================================= -# INTEGRATE SERVICE IN YUNOHOST -#================================================= -ynh_script_progression --message="Integrating service in YunoHost..." - -yunohost service add $app --description="$app daemon for Peertube" --log="/var/log/$app/$app.log" --needs_exposed_ports $port_rtmp - #================================================= # START SYSTEMD SERVICE #================================================= diff --git a/scripts/remove b/scripts/remove index 5c06b4d..5ddde0f 100644 --- a/scripts/remove +++ b/scripts/remove @@ -28,11 +28,6 @@ then yunohost service remove $app fi -#================================================= -# STOP AND REMOVE SERVICE -#================================================= -ynh_script_progression --message="Stopping and removing the systemd service..." - # Remove the dedicated systemd config ynh_remove_systemd_config diff --git a/scripts/restore b/scripts/restore index cecdfc9..ee86baa 100644 --- a/scripts/restore +++ b/scripts/restore @@ -29,6 +29,13 @@ ynh_restore_file --origin_path="$data_dir" --not_mandatory chown -R $app:www-data "$data_dir" +#================================================= +# RESTORE THE POSTGRESQL DATABASE +#================================================= +ynh_script_progression --message="Restoring the PostgreSQL database..." + +ynh_psql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./db.sql + #================================================= # SPECIFIC RESTORATION #================================================= @@ -40,18 +47,6 @@ ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" -#================================================= -# RESTORE THE POSTGRESQL DATABASE -#================================================= -ynh_script_progression --message="Restoring the PostgreSQL database..." - -ynh_psql_execute_file_as_root --file="./db.sql" --database=$db_name - -#================================================= -# RESTORE SYSTEMD -#================================================= -ynh_script_progression --message="Restoring the systemd configuration..." - ynh_restore_file --origin_path="/etc/systemd/system/$app.service" systemctl enable $app.service --quiet diff --git a/scripts/upgrade b/scripts/upgrade index 7cae765..ca1757c 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -89,14 +89,20 @@ ynh_script_progression --message="Upgrading dependencies..." ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version -#================================================= -# NGINX CONFIGURATION -#================================================= -ynh_script_progression --message="Upgrading NGINX web server configuration..." - # Create a dedicated NGINX config ynh_add_nginx_config +# Create a dedicated systemd config +ynh_add_systemd_config + +mkdir -p "/var/log/$app" +chown -R $app:$app "/var/log/$app" + +# Use logrotate to manage app-specific logfile(s) +ynh_use_logrotate --non-append + +yunohost service add $app --description="$app daemon for Peertube" --log="/var/log/$app/$app.log" --needs_exposed_ports $port_rtmp + #================================================= # Generate secrets if they don't exist #================================================= @@ -133,40 +139,15 @@ ynh_backup_if_checksum_is_different --file="$install_dir/config/local-production chmod 600 "$install_dir/config/local-production.json" chown $app:$app "$install_dir/config/local-production.json" -#================================================= -# SETUP SYSTEMD -#================================================= -ynh_script_progression --message="Upgrading systemd configuration..." - -# Create a dedicated systemd config -ynh_add_systemd_config - -#================================================= -# START SYSTEMD SERVICE -#================================================= -ynh_script_progression --message="Starting a systemd service..." - -mkdir -p "/var/log/$app" -chown -R $app:$app "/var/log/$app" -# Start a systemd service -ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="Started" - #================================================= # INSTALL LDAP PLUGIN #================================================= -ynh_script_progression --message="Installing LDAP plugin..." +ynh_script_progression --message="Installing $app plugin..." pushd "$install_dir" ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH NODE_CONFIG_DIR="$install_dir/config" NODE_ENV=production $ynh_npm run plugin:install -- --npm-name peertube-plugin-auth-ldap -popd - -#================================================= -# INSTALL PEERTUBE LIVECHAT PLUGIN -#================================================= -ynh_script_progression --message="Installing PeerTube livechat plugin..." - -pushd "$install_dir" ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH NODE_CONFIG_DIR="$install_dir/config" NODE_ENV=production $ynh_npm run plugin:install -- --npm-name peertube-plugin-livechat + popd #================================================= @@ -187,31 +168,6 @@ if ynh_compare_current_package_version --comparison lt --version 4.2.0~ynh1; the popd fi -#================================================= -# STOP SYSTEMD SERVICE -#================================================= -ynh_script_progression --message="Stopping a systemd service..." - -# Stop a systemd service -ynh_systemd_action --service_name=$app --action="stop" --log_path="systemd" --line_match="Stopped" - -#================================================= -# GENERIC FINALIZATION -#================================================= -# SETUP LOGROTATE -#================================================= -ynh_script_progression --message="Upgrading logrotate configuration..." - -# Use logrotate to manage app-specific logfile(s) -ynh_use_logrotate --non-append - -#================================================= -# INTEGRATE SERVICE IN YUNOHOST -#================================================= -ynh_script_progression --message="Integrating service in YunoHost..." - -yunohost service add $app --description="$app daemon for Peertube" --log="/var/log/$app/$app.log" --needs_exposed_ports $port_rtmp - #================================================= # START SYSTEMD SERVICE #=================================================