1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/snipeit_ynh.git synced 2024-09-03 20:26:16 +02:00

Coding style, etc

This commit is contained in:
Salamandar 2024-07-12 22:48:02 +02:00
parent 846ca59e36
commit f4a790ff70
7 changed files with 100 additions and 119 deletions

View file

@ -1,3 +1,5 @@
#:schema https://raw.githubusercontent.com/YunoHost/apps/master/schemas/manifest.v2.schema.json
packaging_format = 2
id = "snipeit"

View file

@ -1,7 +1,5 @@
#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
@ -22,19 +20,13 @@ ynh_print_info --message="Declaring files to be backed up..."
ynh_backup --src_path="$install_dir"
#=================================================
# BACKUP THE NGINX CONFIGURATION
# SYSTEM CONFIGURATION
#=================================================
ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
#=================================================
# BACKUP THE PHP-FPM CONFIGURATION
#=================================================
ynh_backup --src_path="/etc/php/$phpversion/fpm/pool.d/$app.conf"
#=================================================
# SPECIFIC BACKUP
#=================================================
# BACKUP THE MYSQL DATABASE
#=================================================

View file

@ -1,7 +1,5 @@
#!/bin/bash
#=================================================
# GENERIC STARTING
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
@ -21,7 +19,9 @@ ynh_change_url_nginx_config
#=================================================
ynh_script_progression --message="Adding a configuration file..." --weight=1
ynh_replace_string --match_string="APP_URL=https://$old_domain" --replace_string="APP_URL=https://$new_domain" --target_file=$install_dir/.env
ynh_replace_string --target_file="$install_dir/.env" \
--match_string="APP_URL=https://$old_domain" \
--replace_string="APP_URL=https://$new_domain"
#=================================================
# END OF SCRIPT

View file

@ -1,7 +1,5 @@
#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
@ -10,7 +8,13 @@ source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# APP "BUILD" (DEPLOYING SOURCES, VENV, COMPILING ETC)
# INITIALIZE AND STORE SETTINGS
#=================================================
# fr -> fr-FR
language="${language}-${language^^}"
ynh_app_setting_set --app="$app" --key="language" --value="$language"
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
@ -18,13 +22,49 @@ ynh_script_progression --message="Setting up source files..." --weight=2
ynh_setup_source --dest_dir="$install_dir"
chown -R $app:www-data "$install_dir"
chown -R "$app:www-data" "$install_dir"
# setup page tries to access https://$domain$path/.env and fails on self signed certs
ynh_replace_string --target_file="$install_dir/app/Http/Controllers/SettingsController.php" \
--match_string="->get(URL::to('.env'))" \
--replace_string="->withoutVerifying()->get(URL::to('.env'))"
#=================================================
# ADD A CONFIGURATION
#=================================================
ynh_script_progression --message="Adding $app's configuration file..." --weight=1
app_key=""
ynh_add_config --template="snipeit.env" --destination="$install_dir/.env"
chmod 600 "$install_dir/.env"
chown "$app:$app" "$install_dir/.env"
#=================================================
# BUILDING
#=================================================
ynh_script_progression --message="Building $app..."
ynh_install_composer
# setup application config
pushd "$install_dir"
ynh_exec_as "$app" "php$phpversion" artisan key:generate -n --force --env
ynh_exec_as "$app" "php$phpversion" artisan migrate -n --force
ynh_exec_as "$app" "php$phpversion" artisan config:clear -n
ynh_exec_as "$app" "php$phpversion" artisan config:cache -n
popd
app_key="$(grep "^APP_KEY=" "$install_dir/.env" | cut -d= -f2)"
ynh_app_setting_set --app="$app" --key="app_key" --value="$app_key"
ynh_store_file_checksum --file="$install_dir/.env"
# Set permissions to app files
chown -R "$app:www-data" "$install_dir"
chmod -R o-rwx "$install_dir"
chmod -R 755 "$install_dir/storage"
chmod -R 755 "$install_dir/public/uploads"
#=================================================
# SYSTEM CONFIGURATION
#=================================================
@ -34,44 +74,6 @@ ynh_add_fpm_config
ynh_add_nginx_config
ynh_install_composer
#=================================================
# APP INITIAL CONFIGURATION
#=================================================
# ADD A CONFIGURATION
#=================================================
ynh_script_progression --message="Adding a configuration file..." --weight=1
app_key=""
ynh_add_config --template="snipeit.env" --destination="$install_dir/.env"
chmod 600 "$install_dir/.env"
chown $app:$app "$install_dir/.env"
#=================================================
# BUILDING
#=================================================
ynh_script_progression --message="Building..."
# setup application config
pushd "$install_dir"
php$phpversion artisan key:generate -n --force --env
php$phpversion artisan migrate -n --force
php$phpversion artisan config:clear -n
php$phpversion artisan config:cache -n
popd
app_key="$(grep "^APP_KEY=" "$install_dir/.env" | cut -d= -f2)"
ynh_app_setting_set --app=$app --key=app_key --value=$app_key
ynh_store_file_checksum --file="$install_dir/.env"
# Set permissions to app files
chown -R $app:www-data $install_dir
chmod -R o-rwx $install_dir
chmod -R 755 $install_dir/storage
chmod -R 755 $install_dir/public/uploads
#=================================================
# END OF SCRIPT
#=================================================

View file

@ -1,7 +1,5 @@
#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================

View file

@ -1,7 +1,5 @@
#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
@ -18,14 +16,14 @@ ynh_script_progression --message="Restoring the app main directory..." --weight=
ynh_restore_file --origin_path="$install_dir"
chmod -R o-rwx "$install_dir"
chown -R $app:www-data "$install_dir"
chown -R "$app:www-data" "$install_dir"
#=================================================
# RESTORE THE MYSQL DATABASE
#=================================================
ynh_script_progression --message="Restoring the MySQL database..."
ynh_mysql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./db.sql
ynh_mysql_connect_as --user="$db_user" --password="$db_pwd" --database="$db_name" < ./db.sql
#=================================================
# RESTORE SYSTEM CONFIGURATIONS
@ -36,14 +34,12 @@ ynh_restore_file --origin_path="/etc/php/$phpversion/fpm/pool.d/$app.conf"
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
#=================================================
# GENERIC FINALIZATION
#=================================================
# RELOAD NGINX AND PHP-FPM OR THE APP SERVICE
#=================================================
ynh_script_progression --message="Reloading NGINX web server and PHP-FPM..." --weight=1
ynh_systemd_action --service_name=php$phpversion-fpm --action=reload
ynh_systemd_action --service_name="php$phpversion-fpm" --action=reload
ynh_systemd_action --service_name=nginx --action=reload
#=================================================

View file

@ -1,7 +1,5 @@
#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
@ -9,14 +7,6 @@
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# CHECK VERSION
#=================================================
upgrade_type=$(ynh_check_app_version_changed)
#=================================================
# STANDARD UPGRADE STEPS
#=================================================
# ENSURE DOWNWARD COMPATIBILITY
#=================================================
@ -28,21 +18,59 @@ if [ -z "$app_key" ]; then
ynh_app_setting_set --app=$app --key=app_key --value=$app_key
fi
#=================================================
# "REBUILD" THE APP (DEPLOY NEW SOURCES, RERUN COMPOSER BUILD...)
if (( ${#language} == 2 )); then
# fr -> fr-FR
language="${language}-${language^^}"
ynh_app_setting_set --app="$app" --key="language" --value="$language"
fi
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
ynh_script_progression --message="Upgrading source files..." --weight=7
if [ "$upgrade_type" == "UPGRADE_APP" ]
then
ynh_script_progression --message="Upgrading source files..." --weight=7
# Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source --dest_dir="$install_dir" --keep=".env storage/oauth-private.key storage/oauth-public.key storage/private_uploads public/uploads"
# Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source --dest_dir="$install_dir" --keep=".env storage/oauth-private.key storage/oauth-public.key storage/private_uploads public/uploads"
fi
chown -R "$app:www-data" "$install_dir"
chown -R $app:www-data "$install_dir"
# setup page tries to access https://$domain$path/.env and fails on self signed certs
ynh_replace_string --target_file="$install_dir/app/Http/Controllers/SettingsController.php" \
--match_string="->get(URL::to('.env'))" \
--replace_string="->withoutVerifying()->get(URL::to('.env'))"
#=================================================
# UPDATE A CONFIG FILE
#=================================================
ynh_script_progression --message="Updating a configuration file..."
ynh_backup_if_checksum_is_different --file="$install_dir/.env"
# Recalculate and store the checksum of the file for the next upgrade.
ynh_store_file_checksum --file="$install_dir/.env"
# XXX: Regenerate .env instead ?
# ynh_add_config --template="snipeit.env" --destination="$install_dir/.env"
#=================================================
# BUILDING
#=================================================
ynh_script_progression --message="Building $app..."
ynh_install_composer
ynh_exec_warn_less ynh_composer_exec --commands="dump-autoload"
pushd "$install_dir"
ynh_exec_as "$app" "php$phpversion" artisan migrate -n --force
ynh_exec_as "$app" "php$phpversion" artisan config:clear -n
ynh_exec_as "$app" "php$phpversion" artisan config:cache -n
popd
# Set permissions on app files
chown -R "$app:www-data" "$install_dir"
chmod -R o-rwx "$install_dir"
chmod -R 755 "$install_dir/storage"
chmod -R 755 "$install_dir/public/uploads"
#=================================================
# REAPPLY SYSTEM CONFIGURATIONS
@ -53,43 +81,6 @@ ynh_add_fpm_config
ynh_add_nginx_config
#=================================================
# INSTALL AND INITIALIZE COMPOSER
#=================================================
ynh_script_progression --message="Installing Composer..." --weight=15
ynh_install_composer
ynh_exec_warn_less ynh_composer_exec --commands="dump-autoload"
#=================================================
# UPDATE A CONFIG FILE
#=================================================
ynh_script_progression --message="Updating a configuration file..."
ynh_backup_if_checksum_is_different --file="$install_dir/.env"
# Recalculate and store the checksum of the file for the next upgrade.
ynh_store_file_checksum --file="$install_dir/.env"
# XXX: Regenerate .env instead ?
# ynh_add_config --template="snipeit.env" --destination="$install_dir/.env"
#=================================================
# BUILDING
#=================================================
ynh_script_progression --message="Building..."
pushd "$install_dir"
php$phpversion artisan migrate -n --force
php$phpversion artisan config:clear -n
php$phpversion artisan config:cache -n
popd
# Set permissions on app files
chown -R $app:www-data $install_dir
chmod -R o-rwx $install_dir
chmod -R 755 $install_dir/storage
chmod -R 755 $install_dir/public/uploads
#=================================================
# END OF SCRIPT
#=================================================