mirror of
https://github.com/YunoHost-Apps/snipeit_ynh.git
synced 2024-09-03 20:26:16 +02:00
Merge 85b543f52b
into bc2fd6a847
This commit is contained in:
commit
e33a6ccc96
10 changed files with 89 additions and 104 deletions
|
@ -1,4 +0,0 @@
|
|||
; Additional php.ini defines, specific to this pool of workers.
|
||||
|
||||
php_admin_value[upload_max_filesize] = 50M
|
||||
php_admin_value[post_max_size] = 50M
|
|
@ -12,7 +12,7 @@ location ^~ __PATH__/ {
|
|||
try_files $uri $uri/ @snipe;
|
||||
location ~ \.php {
|
||||
fastcgi_split_path_info ^(.+?\.php)(/.*)$;
|
||||
fastcgi_pass unix:/var/run/php/php__PHPVERSION__-fpm-__NAME__.sock;
|
||||
fastcgi_pass unix:/var/run/php/php__PHP_VERSION__-fpm-__APP__.sock;
|
||||
|
||||
fastcgi_index index.php;
|
||||
include fastcgi_params;
|
||||
|
|
|
@ -22,7 +22,8 @@ cpe = "cpe:2.3:a:snipeitapp:snipe-it"
|
|||
fund = "https://snipeitapp.com/donate"
|
||||
|
||||
[integration]
|
||||
yunohost = ">= 11.2"
|
||||
yunohost = ">= 11.2.18"
|
||||
helpers_version = "2.1"
|
||||
architectures = "all"
|
||||
multi_instance = false
|
||||
|
||||
|
@ -60,6 +61,7 @@ ram.runtime = "50M"
|
|||
allow_email = true
|
||||
|
||||
[resources.install_dir]
|
||||
group = "www-data:r-x"
|
||||
|
||||
[resources.permissions]
|
||||
main.url = "/"
|
||||
|
|
|
@ -1,20 +1,11 @@
|
|||
#!/bin/bash
|
||||
|
||||
#=================================================
|
||||
# COMMON VARIABLES
|
||||
# COMMON VARIABLES AND CUSTOM HELPERS
|
||||
#=================================================
|
||||
|
||||
# Packages requirements: https://snipe-it.readme.io/docs/requirements
|
||||
|
||||
YNH_COMPOSER_VERSION=2.5.8
|
||||
composer_version=2.5.8
|
||||
|
||||
timezone=$(cat /etc/timezone)
|
||||
|
||||
#=================================================
|
||||
# PERSONAL HELPERS
|
||||
#=================================================
|
||||
|
||||
#=================================================
|
||||
# EXPERIMENTAL HELPERS
|
||||
#=================================================
|
||||
|
||||
|
|
|
@ -8,34 +8,31 @@
|
|||
source ../settings/scripts/_common.sh
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
#=================================================
|
||||
# DECLARE DATA AND CONF FILES TO BACKUP
|
||||
#=================================================
|
||||
ynh_print_info --message="Declaring files to be backed up..."
|
||||
ynh_print_info "Declaring files to be backed up..."
|
||||
|
||||
#=================================================
|
||||
# BACKUP THE APP MAIN DIR
|
||||
#=================================================
|
||||
|
||||
ynh_backup --src_path="$install_dir"
|
||||
ynh_backup "$install_dir"
|
||||
|
||||
#=================================================
|
||||
# SYSTEM CONFIGURATION
|
||||
#=================================================
|
||||
|
||||
ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
|
||||
ynh_backup --src_path="/etc/php/$phpversion/fpm/pool.d/$app.conf"
|
||||
ynh_backup "/etc/php/$php_version/fpm/pool.d/$app.conf"
|
||||
|
||||
#=================================================
|
||||
# BACKUP THE MYSQL DATABASE
|
||||
#=================================================
|
||||
ynh_print_info --message="Backing up the MySQL database..."
|
||||
ynh_print_info "Backing up the MySQL database..."
|
||||
|
||||
ynh_mysql_dump_db --database="$db_name" > db.sql
|
||||
ynh_mysql_dump_db > db.sql
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_print_info --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)."
|
||||
ynh_print_info "Backup script completed for $app. (YunoHost will then actually copy those files to the archive)."
|
||||
|
|
|
@ -10,26 +10,26 @@ source /usr/share/yunohost/helpers
|
|||
#=================================================
|
||||
# MODIFY URL IN NGINX CONF
|
||||
#=================================================
|
||||
ynh_script_progression --message="Updating NGINX web server configuration..." --weight=1
|
||||
ynh_script_progression "Updating NGINX web server configuration..."
|
||||
|
||||
ynh_change_url_nginx_config
|
||||
ynh_config_change_url_nginx
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC MODIFICATIONS
|
||||
#=================================================
|
||||
ynh_script_progression --message="Adding a configuration file..." --weight=1
|
||||
ynh_script_progression "Adding $app's configuration..."
|
||||
|
||||
ynh_replace_string --target_file="$install_dir/.env" \
|
||||
--match_string="APP_URL=https://$old_domain" \
|
||||
--replace_string="APP_URL=https://$new_domain"
|
||||
ynh_replace --file="$install_dir/.env" \
|
||||
--match="APP_URL=https://$old_domain" \
|
||||
--replace="APP_URL=https://$new_domain"
|
||||
|
||||
pushd "$install_dir"
|
||||
ynh_exec_as "$app" "php$phpversion" artisan config:clear -n
|
||||
ynh_exec_as "$app" "php$phpversion" artisan config:cache -n
|
||||
ynh_exec_as_app "php$php_version" artisan config:clear -n
|
||||
ynh_exec_as_app "php$php_version" artisan config:cache -n
|
||||
popd
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_script_progression --message="Change of URL completed for $app" --last
|
||||
ynh_script_progression "Change of URL completed for $app"
|
||||
|
|
|
@ -13,69 +13,69 @@ source /usr/share/yunohost/helpers
|
|||
|
||||
# fr -> fr-FR
|
||||
language="${language}-${language^^}"
|
||||
ynh_app_setting_set --app="$app" --key="language" --value="$language"
|
||||
ynh_app_setting_set --key="language" --value="$language"
|
||||
|
||||
#=================================================
|
||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Setting up source files..." --weight=2
|
||||
ynh_script_progression "Setting up source files..."
|
||||
|
||||
ynh_setup_source --dest_dir="$install_dir"
|
||||
|
||||
chown -R "$app:www-data" "$install_dir"
|
||||
|
||||
#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | 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'))"
|
||||
ynh_replace --file="$install_dir/app/Http/Controllers/SettingsController.php" \
|
||||
--match="->get(URL::to('.env'))" \
|
||||
--replace="->withoutVerifying()->get(URL::to('.env'))"
|
||||
|
||||
#=================================================
|
||||
# ADD A CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Adding $app's configuration file..." --weight=1
|
||||
ynh_script_progression "Adding $app's configuration file..."
|
||||
|
||||
app_key=""
|
||||
ynh_add_config --template="snipeit.env" --destination="$install_dir/.env"
|
||||
ynh_config_add --template="snipeit.env" --destination="$install_dir/.env"
|
||||
|
||||
chmod 600 "$install_dir/.env"
|
||||
chown "$app:$app" "$install_dir/.env"
|
||||
#REMOVEME? Assuming the file is setup using ynh_config_add, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod 600 "$install_dir/.env"
|
||||
#REMOVEME? Assuming the file is setup using ynh_config_add, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown "$app:$app" "$install_dir/.env"
|
||||
|
||||
#=================================================
|
||||
# BUILDING
|
||||
#=================================================
|
||||
ynh_script_progression --message="Building $app..."
|
||||
ynh_script_progression "Building $app..."
|
||||
|
||||
ynh_install_composer
|
||||
ynh_composer_install
|
||||
ynh_composer_exec install --no-dev
|
||||
|
||||
# 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
|
||||
ynh_exec_as_app "php$php_version" artisan key:generate -n --force --env
|
||||
ynh_exec_as_app "php$php_version" artisan migrate -n --force
|
||||
ynh_exec_as_app "php$php_version" artisan config:clear -n
|
||||
ynh_exec_as_app "php$php_version" 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"
|
||||
ynh_app_setting_set --key="app_key" --value="$app_key"
|
||||
ynh_store_file_checksum "$install_dir/.env"
|
||||
|
||||
# Set permissions to app files
|
||||
chown -R "$app:www-data" "$install_dir"
|
||||
chmod -R o-rwx "$install_dir"
|
||||
#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown -R "$app:www-data" "$install_dir"
|
||||
#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod -R o-rwx "$install_dir"
|
||||
chmod -R 755 "$install_dir/storage"
|
||||
chmod -R 755 "$install_dir/public/uploads"
|
||||
|
||||
#=================================================
|
||||
# SYSTEM CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Adding system configurations related to $app..." --weight=1
|
||||
ynh_script_progression "Adding system configurations related to $app..."
|
||||
|
||||
ynh_add_fpm_config
|
||||
ynh_config_add_phpfpm
|
||||
|
||||
ynh_add_nginx_config
|
||||
ynh_config_add_nginx
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_script_progression --message="Installation of $app completed" --last
|
||||
ynh_script_progression "Installation of $app completed"
|
||||
|
|
|
@ -10,14 +10,14 @@ source /usr/share/yunohost/helpers
|
|||
#=================================================
|
||||
# REMOVE SYSTEM CONFIGURATIONS
|
||||
#=================================================
|
||||
ynh_script_progression --message="Removing system configurations related to $app..." --weight=1
|
||||
ynh_script_progression "Removing system configurations related to $app..."
|
||||
|
||||
ynh_remove_nginx_config
|
||||
ynh_config_remove_nginx
|
||||
|
||||
ynh_remove_fpm_config
|
||||
ynh_config_remove_phpfpm
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_script_progression --message="Removal of $app completed"
|
||||
ynh_script_progression "Removal of $app completed"
|
||||
|
|
|
@ -11,39 +11,38 @@ source /usr/share/yunohost/helpers
|
|||
#=================================================
|
||||
# RESTORE THE APP MAIN DIR
|
||||
#=================================================
|
||||
ynh_script_progression --message="Restoring the app main directory..." --weight=7
|
||||
ynh_script_progression "Restoring the app main directory..."
|
||||
|
||||
ynh_restore_file --origin_path="$install_dir"
|
||||
|
||||
chmod -R o-rwx "$install_dir"
|
||||
chown -R "$app:www-data" "$install_dir"
|
||||
ynh_restore "$install_dir"
|
||||
|
||||
#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod -R o-rwx "$install_dir"
|
||||
#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown -R "$app:www-data" "$install_dir"
|
||||
#=================================================
|
||||
# RESTORE THE MYSQL DATABASE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Restoring the MySQL database..."
|
||||
ynh_script_progression "Restoring the MySQL database..."
|
||||
|
||||
ynh_mysql_connect_as --user="$db_user" --password="$db_pwd" --database="$db_name" < ./db.sql
|
||||
ynh_mysql_db_shell < ./db.sql
|
||||
|
||||
#=================================================
|
||||
# RESTORE SYSTEM CONFIGURATIONS
|
||||
#=================================================
|
||||
ynh_script_progression --message="Restoring system configurations related to $app..." --weight=1
|
||||
ynh_script_progression "Restoring system configurations related to $app..."
|
||||
|
||||
ynh_restore_file --origin_path="/etc/php/$phpversion/fpm/pool.d/$app.conf"
|
||||
ynh_restore "/etc/php/$php_version/fpm/pool.d/$app.conf"
|
||||
|
||||
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
ynh_restore "/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
|
||||
#=================================================
|
||||
# RELOAD NGINX AND PHP-FPM OR THE APP SERVICE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Reloading NGINX web server and PHP-FPM..." --weight=1
|
||||
ynh_script_progression "Reloading NGINX web server and PHP-FPM..."
|
||||
|
||||
ynh_systemd_action --service_name="php$phpversion-fpm" --action=reload
|
||||
ynh_systemd_action --service_name=nginx --action=reload
|
||||
ynh_systemctl --service="php$php_version-fpm" --action=reload
|
||||
ynh_systemctl --service=nginx --action=reload
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_script_progression --message="Restoration completed for $app"
|
||||
ynh_script_progression "Restoration completed for $app"
|
||||
|
|
|
@ -10,79 +10,79 @@ source /usr/share/yunohost/helpers
|
|||
#=================================================
|
||||
# ENSURE DOWNWARD COMPATIBILITY
|
||||
#=================================================
|
||||
ynh_script_progression --message="Ensuring downward compatibility..." --weight=1
|
||||
ynh_script_progression "Ensuring downward compatibility..."
|
||||
|
||||
# If app_key doesn't exist, create it
|
||||
if [ -z "$app_key" ]; then
|
||||
app_key="$(grep "^APP_KEY=" "$install_dir/.env" | cut -d= -f2)"
|
||||
ynh_app_setting_set --app=$app --key=app_key --value=$app_key
|
||||
ynh_app_setting_set --key=app_key --value=$app_key
|
||||
fi
|
||||
|
||||
if (( ${#language} == 2 )); then
|
||||
# fr -> fr-FR
|
||||
language="${language}-${language^^}"
|
||||
ynh_app_setting_set --app="$app" --key="language" --value="$language"
|
||||
ynh_app_setting_set --key="language" --value="$language"
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Upgrading source files..." --weight=7
|
||||
ynh_script_progression "Upgrading source files..."
|
||||
|
||||
# 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"
|
||||
|
||||
chown -R "$app:www-data" "$install_dir"
|
||||
|
||||
#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | 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'))"
|
||||
ynh_replace --file="$install_dir/app/Http/Controllers/SettingsController.php" \
|
||||
--match="->get(URL::to('.env'))" \
|
||||
--replace="->withoutVerifying()->get(URL::to('.env'))"
|
||||
|
||||
#=================================================
|
||||
# UPDATE A CONFIG FILE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Updating a configuration file..."
|
||||
ynh_script_progression "Updating configuration..."
|
||||
|
||||
ynh_backup_if_checksum_is_different --file="$install_dir/.env"
|
||||
ynh_backup_if_checksum_is_different "$install_dir/.env"
|
||||
|
||||
# Recalculate and store the checksum of the file for the next upgrade.
|
||||
ynh_store_file_checksum --file="$install_dir/.env"
|
||||
ynh_store_file_checksum "$install_dir/.env"
|
||||
# XXX: Regenerate .env instead ?
|
||||
# ynh_add_config --template="snipeit.env" --destination="$install_dir/.env"
|
||||
# ynh_config_add --template="snipeit.env" --destination="$install_dir/.env"
|
||||
|
||||
#=================================================
|
||||
# BUILDING
|
||||
#=================================================
|
||||
ynh_script_progression --message="Building $app..."
|
||||
ynh_script_progression "Building $app..."
|
||||
|
||||
ynh_install_composer
|
||||
ynh_composer_install
|
||||
ynh_composer_exec install --no-dev
|
||||
|
||||
ynh_exec_warn_less ynh_composer_exec --commands="dump-autoload"
|
||||
ynh_composer_exec 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
|
||||
ynh_exec_as_app "php$php_version" artisan migrate -n --force
|
||||
ynh_exec_as_app "php$php_version" artisan config:clear -n
|
||||
ynh_exec_as_app "php$php_version" artisan config:cache -n
|
||||
popd
|
||||
|
||||
# Set permissions on app files
|
||||
chown -R "$app:www-data" "$install_dir"
|
||||
chmod -R o-rwx "$install_dir"
|
||||
#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown -R "$app:www-data" "$install_dir"
|
||||
#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod -R o-rwx "$install_dir"
|
||||
chmod -R 755 "$install_dir/storage"
|
||||
chmod -R 755 "$install_dir/public/uploads"
|
||||
|
||||
#=================================================
|
||||
# REAPPLY SYSTEM CONFIGURATIONS
|
||||
#=================================================
|
||||
ynh_script_progression --message="Upgrading system configurations related to $app..." --weight=1
|
||||
ynh_script_progression "Upgrading system configurations related to $app..."
|
||||
|
||||
ynh_add_fpm_config
|
||||
ynh_config_add_phpfpm
|
||||
|
||||
ynh_add_nginx_config
|
||||
ynh_config_add_nginx
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_script_progression --message="Upgrade of $app completed"
|
||||
ynh_script_progression "Upgrade of $app completed"
|
||||
|
|
Loading…
Add table
Reference in a new issue