1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/peertube_ynh.git synced 2024-09-03 19:56:29 +02:00

Cleanup scripts x_x

This commit is contained in:
Alexandre Aubin 2023-12-27 18:10:54 +01:00
parent 5f7d4fbede
commit b62061a719
3 changed files with 33 additions and 53 deletions

View file

@ -16,36 +16,26 @@ source /usr/share/yunohost/helpers
admin_mail=$(ynh_user_get_info --username=$admin --key="mail")
admin_pass=$(ynh_string_random --length=24)
secrets_peertube=$(ynh_string_random --length=24)
#=================================================
# STORE SETTINGS FROM MANIFEST
#=================================================
ynh_script_progression --message="Storing installation settings..."
ynh_app_setting_set --app=$app --key=secrets_peertube --value=$secrets_peertube
redis_db=$(ynh_redis_get_free_db)
ynh_app_setting_set --app="$app" --key=redis_db --value="$redis_db"
#=================================================
# INSTALL DEPENDENCIES
#=================================================
ynh_script_progression --message="Installing dependencies..."
ynh_script_progression --message="Installing nodejs..."
ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version
#=================================================
# CREATE A POSTGRESQL DATABASE
#=================================================
ynh_script_progression --message="Creating a PostgreSQL database..."
ynh_script_progression --message="Initializing postgresql modules..."
ynh_psql_execute_as_root --sql="CREATE EXTENSION IF NOT EXISTS unaccent;" --database=$db_name
ynh_psql_execute_as_root --sql="CREATE EXTENSION IF NOT EXISTS pg_trgm;" --database=$db_name
#=================================================
# CONFIGURE REDIS
#=================================================
redis_db=$(ynh_redis_get_free_db)
ynh_app_setting_set --app="$app" --key=redis_db --value="$redis_db"
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
@ -110,7 +100,7 @@ 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
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
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
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
#=================================================

View file

@ -45,6 +45,8 @@ ynh_script_progression --message="Reinstalling dependencies..."
ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version
ynh_script_progression --message="Reinstalling system configurations..."
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
ynh_restore_file --origin_path="/etc/systemd/system/$app.service"

View file

@ -14,22 +14,8 @@ source /usr/share/yunohost/helpers
#=================================================
admin_mail=$(ynh_user_get_info --username=$admin --key="mail")
#=================================================
# CHECK VERSION
#=================================================
upgrade_type=$(ynh_check_app_version_changed)
#=================================================
# STANDARD UPGRADE STEPS
#=================================================
# STOP SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Stopping a systemd service..."
ynh_systemd_action --service_name=$app --action="stop" --log_path="systemd" --line_match="Stopped"
#=================================================
# ENSURE DOWNWARD COMPATIBILITY
#=================================================
@ -39,11 +25,17 @@ ynh_app_setting_delete --app=$app --key=admin_pass
ynh_app_setting_delete --app=$app --key=admin_mail
# If redis_db doesn't exist, create it
if [ -z "$redis_db" ]; then
if [ -z "${redis_db:-}" ]; then
redis_db=$(ynh_redis_get_free_db)
ynh_app_setting_set --app="$app" --key=redis_db --value="$redis_db"
fi
if [ -z "${secrets_peertube:-}" ]; then
ynh_print_info --message="Generating and storing PeerTube secrets..."
secrets_peertube=$(ynh_string_random --length=24)
ynh_app_setting_set --app=$app --key=secrets_peertube --value=$secrets_peertube
fi
# Add PostgreSQL extension for v1.0.0-beta.10.pre.1
ynh_psql_execute_as_root --sql="CREATE EXTENSION IF NOT EXISTS unaccent;" --database=$db_name
ynh_psql_execute_as_root --sql="CREATE EXTENSION IF NOT EXISTS pg_trgm;" --database=$db_name
@ -51,17 +43,22 @@ ynh_psql_execute_as_root --sql="CREATE EXTENSION IF NOT EXISTS pg_trgm;" --datab
# Remove repository
ynh_secure_remove --file="/etc/apt/sources.list.d/yarn.list"
# Remove not needed checksum
ynh_delete_file_checksum --file="../conf/msg_install"
# Remove hook
if [[ -e "/usr/share/yunohost/hooks/conf_regen/15-nginx_$app" ]]
then
ynh_secure_remove --file="/usr/share/yunohost/hooks/conf_regen/15-nginx_$app"
yunohost tools regen-conf nginx
fi
# Remove old log file
ynh_secure_remove --file="$data_dir/logs"
mkdir -p "/var/log/$app"
chown -R $app:$app "/var/log/$app"
#=================================================
# STOP SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Stopping a systemd service..."
ynh_systemd_action --service_name=$app --action="stop" --log_path="systemd" --line_match="Stopped"
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
@ -86,6 +83,8 @@ ynh_script_progression --message="Upgrading dependencies..."
ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version
ynh_script_progression --message="Upgrading system configurations..."
# Create a dedicated NGINX config
ynh_add_nginx_config
@ -100,16 +99,6 @@ ynh_use_logrotate --non-append
yunohost service add $app --description="Federated video streaming platform" --log="/var/log/$app/$app.log" --needs_exposed_ports $port_rtmp
#=================================================
# Generate secrets if they don't exist
#=================================================
if [ -z "$secrets_peertube" ]; then
ynh_print_info --message="Generating and storing PeerTube secrets..."
secrets_peertube=$(ynh_string_random --length=24)
ynh_app_setting_set --app=$app --key=secrets_peertube --value=$secrets_peertube
fi
#=================================================
# BUILD YARN DEPENDENCIES
#=================================================
@ -124,7 +113,7 @@ popd
#=================================================
# UPDATE A CONFIG FILE
#=================================================
ynh_script_progression --message="Updating a config file..."
ynh_script_progression --message="Updating configuration file..."
ynh_add_config --template="production.yaml" --destination="$install_dir/config/production.yaml"
chmod 400 "$install_dir/config/production.yaml"
@ -141,7 +130,6 @@ 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
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
#=================================================
@ -165,7 +153,7 @@ fi
#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Starting a systemd service..."
ynh_script_progression --message="Starting systemd service..."
ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="HTTP server listening on localhost"