mirror of
https://github.com/YunoHost-Apps/gogs_ynh.git
synced 2024-09-03 20:36:23 +02:00
fix
This commit is contained in:
parent
224225a7ad
commit
90d8a28cf6
4 changed files with 124 additions and 88 deletions
|
@ -35,28 +35,28 @@ ynh_print_info --message="Declaring files to be backed up..."
|
|||
# BACKUP THE APP MAIN DIR
|
||||
#=================================================
|
||||
|
||||
ynh_backup "$final_path"
|
||||
ynh_backup --src_path="$final_path"
|
||||
|
||||
# Copy the data files
|
||||
ynh_backup "$DATADIR"
|
||||
ynh_backup --src_path="/home/$app"
|
||||
|
||||
#=================================================
|
||||
# BACKUP THE NGINX CONFIGURATION
|
||||
#=================================================
|
||||
|
||||
ynh_backup "/etc/nginx/conf.d/${domain}.d/${app}.conf"
|
||||
ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
|
||||
#=================================================
|
||||
# BACKUP SYSTEMD
|
||||
#=================================================
|
||||
|
||||
ynh_backup "/etc/systemd/system/${app}.service"
|
||||
ynh_backup --src_path="/etc/systemd/system/$app.service"
|
||||
|
||||
#=================================================
|
||||
# BACKUP VARIOUS FILES
|
||||
#=================================================
|
||||
|
||||
ynh_backup "/var/log/$app"
|
||||
ynh_backup --src_path="/var/log/$app"
|
||||
|
||||
#=================================================
|
||||
# BACKUP THE MYSQL DATABASE
|
||||
|
|
|
@ -155,14 +155,13 @@ ynh_replace_string --match_string="__ADMIN__" --replace_string="$admin" --target
|
|||
ynh_store_file_checksum --file="$final_path/custom/conf/app.ini"
|
||||
ynh_store_file_checksum --file="$final_path/custom/conf/auth.d/ldap.conf"
|
||||
|
||||
|
||||
# Configure init script
|
||||
ynh_add_systemd_config
|
||||
|
||||
#=================================================
|
||||
# NGINX CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Configuring nginx web server..." --weight=1
|
||||
ynh_script_progression --message="Configuring NGINX web server..." --weight=1
|
||||
|
||||
# Create a dedicated nginx config
|
||||
ynh_add_nginx_config
|
||||
|
@ -180,9 +179,6 @@ chmod u=rwX,g=rX,o= "$final_path"
|
|||
chmod u=rwX,g=rX,o= "/home/$app"
|
||||
chmod u=rwX,g=rX,o= "/var/log/$app"
|
||||
|
||||
# Unprotect root from SSO if public
|
||||
set_access_settings
|
||||
|
||||
#=================================================
|
||||
# INTEGRATE SERVICE IN YUNOHOST
|
||||
#=================================================
|
||||
|
@ -205,6 +201,19 @@ ynh_script_progression --message="Starting a systemd service..." --weight=1
|
|||
# Start a systemd service
|
||||
ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log"
|
||||
|
||||
#=================================================
|
||||
# SETUP SSOWAT
|
||||
#=================================================
|
||||
ynh_script_progression --message="Configuring SSOwat..." --weight=1
|
||||
|
||||
# Make app public if necessary or protect it
|
||||
if [ $is_public -eq 1 ]
|
||||
then
|
||||
# Everyone can access the app.
|
||||
# The "main" permission is automatically created before the install script.
|
||||
ynh_permission_update --permission "main" --add "visitors"
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# RELOAD NGINX
|
||||
#=================================================
|
||||
|
|
|
@ -15,7 +15,6 @@ source /usr/share/yunohost/helpers
|
|||
#=================================================
|
||||
|
||||
ynh_clean_setup () {
|
||||
#### Remove this function if there's nothing to clean before calling the remove script.
|
||||
true
|
||||
}
|
||||
# Exit if an error occurs during the execution of the script
|
||||
|
@ -33,8 +32,6 @@ path_url=$(ynh_app_setting_get --app=$app --key=path)
|
|||
db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd)
|
||||
admin=$(ynh_app_setting_get --app=$app --key=adminusername)
|
||||
|
||||
|
||||
|
||||
# Check domain/path availability with app helper
|
||||
ynh_webpath_available $domain $path_url || ynh_die "$domain is not available as domain, please use an other domain."
|
||||
|
||||
|
|
180
scripts/upgrade
180
scripts/upgrade
|
@ -18,105 +18,135 @@ ynh_script_progression --message="Loading installation settings..." --weight=1
|
|||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
domain=$(ynh_app_setting_get "$app" domain)
|
||||
path_url=$(ynh_normalize_url_path $(ynh_app_setting_get "$app" path))
|
||||
db_pwd=$(ynh_app_setting_get "$app" mysqlpwd)
|
||||
admin=$(ynh_app_setting_get "$app" adminusername)
|
||||
is_public=$(ynh_app_setting_get "$app" is_public)
|
||||
port=$(ynh_app_setting_get "$app" web_port)
|
||||
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||
path_url=$(ynh_app_setting_get --app=$app --key=path)
|
||||
db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd)
|
||||
admin=$(ynh_app_setting_get --app=$app --key=adminusername)
|
||||
is_public=$(ynh_app_setting_get --app=$app --key=is_public)
|
||||
port=$(ynh_app_setting_get --app=$app --key=web_port)
|
||||
|
||||
#=================================================
|
||||
# CHECK VERSION
|
||||
#=================================================
|
||||
|
||||
upgrade_type=$(ynh_check_app_version_changed)
|
||||
|
||||
#=================================================
|
||||
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
|
||||
#=================================================
|
||||
ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=1
|
||||
|
||||
# Backup the current version of the app
|
||||
ynh_backup_before_upgrade
|
||||
ynh_clean_setup () {
|
||||
# Restore it if the upgrade fails
|
||||
ynh_restore_upgradebackup
|
||||
}
|
||||
|
||||
# Stop service
|
||||
systemctl stop "$app".service
|
||||
# Exit if an error occurs during the execution of the script
|
||||
ynh_abort_if_errors
|
||||
|
||||
#=================================================
|
||||
# MIGRATION FROM OLD VERSION
|
||||
# STANDARD UPGRADE STEPS
|
||||
#=================================================
|
||||
# STOP SYSTEMD SERVICE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Stopping a systemd service..." --time --weight=1
|
||||
|
||||
# Update settings is_public to new standard
|
||||
if [ "$is_public" = "Yes" ]; then
|
||||
ynh_app_setting_set $app is_public 1 # Fixe is_public en booléen
|
||||
is_public=1
|
||||
elif [ "$is_public" = "No" ]; then
|
||||
ynh_app_setting_set $app is_public 0
|
||||
is_public=0
|
||||
fi
|
||||
|
||||
if [[ $port == "" ]]
|
||||
then
|
||||
port=$(ynh_find_port 6000)
|
||||
ynh_app_setting_set $app web_port $port
|
||||
fi
|
||||
|
||||
# handle upgrade from old package installation
|
||||
# this test that /etc/gogs exist since this was used in the old package
|
||||
# but not in the new
|
||||
# this code will be removed in the future
|
||||
if [ -d "/etc/gogs" ]
|
||||
then
|
||||
# create needed directories if not already created
|
||||
create_dir
|
||||
|
||||
# move repositories to new dir
|
||||
old_repo_path=$(ynh_app_setting_get "$app" repopath)
|
||||
mv "${old_repo_path:-/home/yunohost.app/gogs}"/* "$REPO_PATH" || true # Avoid if the directory is empty
|
||||
# cleanup old dir and conf
|
||||
ynh_secure_remove /opt/gogs
|
||||
ynh_secure_remove /etc/gogs
|
||||
ynh_secure_remove /opt/gogs_src
|
||||
|
||||
# create needed directories if not already created
|
||||
create_dir
|
||||
fi
|
||||
# end of old package upgrade
|
||||
|
||||
# test if user gogs is locked because of an old installation of the package.
|
||||
# if it's blocked, unlock it to allow ssh usage with git
|
||||
if [[ $(grep "$app" /etc/shadow | cut -d: -f2) == '!' ]]
|
||||
then
|
||||
usermod -p '*' "$app"
|
||||
fi
|
||||
|
||||
# Remove old authentification mecanisme, actually the registry in the database has been replaced by a config file
|
||||
if [[ ! -e "$final_path/custom/conf/auth.d/ldap.conf" ]]
|
||||
then
|
||||
ynh_mysql_connect_as "$db_user" "$db_pwd" "$db_name" <<< "DELETE FROM login_source WHERE name = 'Yunohost LDAP';"
|
||||
mkdir -p "$final_path/custom/conf/auth.d"
|
||||
fi
|
||||
ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log"
|
||||
|
||||
#=================================================
|
||||
# STANDARD UPGRADE STEPS
|
||||
#=================================================
|
||||
|
||||
# Clean template to fix issue : https://github.com/gogits/gogs/issues/4585
|
||||
ynh_secure_remove "/opt/gogs/templates"
|
||||
ynh_secure_remove "/opt/$app/templates"
|
||||
|
||||
# Install Gogs
|
||||
ynh_setup_source $final_path $architecture
|
||||
#=================================================
|
||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Setting up source files..." --weight=3
|
||||
|
||||
# Configure gogs with app.ini file
|
||||
config_gogs
|
||||
ynh_app_setting_set --app=$app --key=final_path --value=$final_path
|
||||
# Download, check integrity, uncompress and patch the source from app.src
|
||||
ynh_setup_source --dest_dir=$final_path --source_id="$architecture"
|
||||
|
||||
# Configure init script
|
||||
ynh_backup_if_checksum_is_different "$final_path/custom/conf/app.ini"
|
||||
ynh_backup_if_checksum_is_different "$final_path/custom/conf/auth.d/ldap.conf"
|
||||
|
||||
cp ../conf/app.ini "$final_path/custom/conf"
|
||||
cp ../conf/ldap.conf "$final_path/custom/conf/auth.d/ldap.conf"
|
||||
|
||||
if [ "$path_url" = "/" ]
|
||||
then
|
||||
ynh_replace_string "__URL__" "$domain" "$final_path/custom/conf/app.ini"
|
||||
else
|
||||
ynh_replace_string "__URL__" "$domain${path_url%/}" "$final_path/custom/conf/app.ini"
|
||||
fi
|
||||
|
||||
ynh_replace_string "__REPOS_PATH__" "$REPO_PATH" "$final_path/custom/conf/app.ini"
|
||||
ynh_replace_string "__DB_PASSWORD__" "$dbpass" "$final_path/custom/conf/app.ini"
|
||||
ynh_replace_string "__DB_USER__" "$dbuser" "$final_path/custom/conf/app.ini"
|
||||
ynh_replace_string "__DOMAIN__" "$domain" "$final_path/custom/conf/app.ini"
|
||||
ynh_replace_string "__KEY__" "$key" "$final_path/custom/conf/app.ini"
|
||||
ynh_replace_string "__DATA_PATH__" "$DATA_PATH" "$final_path/custom/conf/app.ini"
|
||||
ynh_replace_string "__PORT__" $port "$final_path/custom/conf/app.ini"
|
||||
ynh_replace_string "__APP__" $app "$final_path/custom/conf/app.ini"
|
||||
|
||||
if [[ "$is_public" = '1' ]]
|
||||
then
|
||||
ynh_replace_string "__PRIVATE_MODE__" "false" "$final_path/custom/conf/app.ini"
|
||||
else
|
||||
ynh_replace_string "__PRIVATE_MODE__" "true" "$final_path/custom/conf/app.ini"
|
||||
fi
|
||||
|
||||
ynh_replace_string "__ADMIN__" "$admin" "$final_path/custom/conf/auth.d/ldap.conf"
|
||||
|
||||
ynh_store_file_checksum "$final_path/custom/conf/app.ini"
|
||||
ynh_store_file_checksum "$final_path/custom/conf/auth.d/ldap.conf"
|
||||
|
||||
#=================================================
|
||||
# SETUP SYSTEMD
|
||||
#=================================================
|
||||
ynh_script_progression --message="Upgrading systemd configuration..." --time --weight=1
|
||||
|
||||
# Create a dedicated systemd config
|
||||
ynh_add_systemd_config
|
||||
|
||||
# Modify Nginx configuration file and copy it to Nginx conf directory
|
||||
config_nginx
|
||||
#=================================================
|
||||
# NGINX CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Upgrading NGINX web server configuration..." --time --weight=1
|
||||
|
||||
# Create a dedicated NGINX config
|
||||
ynh_add_nginx_config
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALIZATION
|
||||
# SECURE FILES AND DIRECTORIES
|
||||
#=================================================
|
||||
|
||||
# Unprotect root from SSO if public
|
||||
set_access_settings
|
||||
chown -R $app:$app "$final_path"
|
||||
chown -R $app:$app "/home/$app"
|
||||
chown -R $app:$app "/var/log/$app"
|
||||
chmod u=rwX,g=rX,o= "$final_path"
|
||||
chmod u=rwX,g=rX,o= "/home/$app"
|
||||
chmod u=rwX,g=rX,o= "/var/log/$app"
|
||||
|
||||
# Set permissions
|
||||
set_permission
|
||||
#=================================================
|
||||
# INTEGRATE SERVICE IN YUNOHOST
|
||||
#=================================================
|
||||
ynh_script_progression --message="Integrating service in YunoHost..." --weight=1
|
||||
|
||||
# Reload services
|
||||
ynh_check_starting "INFO] Listen: http://0.0.0.0:" "/var/log/$app/gogs.log"
|
||||
yunohost service add "$app" --log="/var/log/$app/$app.log"
|
||||
|
||||
#=================================================
|
||||
# RELOAD NGINX
|
||||
#=================================================
|
||||
ynh_script_progression --message="Reloading NGINX web server..." --time --weight=1
|
||||
|
||||
ynh_systemd_action --service_name=nginx --action=reload
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_script_progression --message="Upgrade of $app completed" --last
|
||||
|
|
Loading…
Reference in a new issue