mirror of
https://github.com/YunoHost-Apps/seafile_ynh.git
synced 2024-09-03 20:26:01 +02:00
[autopatch] Automatic patch attempt for helpers 2.1
This commit is contained in:
parent
5a4717ace8
commit
fd287c9ea4
9 changed files with 148 additions and 154 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -221,3 +221,4 @@ pip-log.txt
|
|||
*-swp
|
||||
|
||||
auto_update_config.sh
|
||||
*.sw[op]
|
||||
|
|
|
@ -18,7 +18,8 @@ code = "https://github.com/haiwen/seafile-server"
|
|||
cpe = "cpe:2.3:a:seafile:seafile"
|
||||
|
||||
[integration]
|
||||
yunohost = ">= 11.2.13"
|
||||
yunohost = ">= 11.2.18"
|
||||
helpers_version = "2.1"
|
||||
architectures = ["amd64", "arm64"]
|
||||
multi_instance = false
|
||||
ldap = true
|
||||
|
@ -65,6 +66,7 @@ ram.runtime = "500M"
|
|||
home = "/opt/yunohost/__APP__"
|
||||
|
||||
[resources.install_dir]
|
||||
group = "www-data:r-x"
|
||||
dir = "/opt/yunohost/__APP__"
|
||||
owner = "__APP__:rwx"
|
||||
group = "www-data:rx"
|
||||
|
|
|
@ -31,7 +31,7 @@ fi
|
|||
#=================================================
|
||||
|
||||
run_seafile_cmd() {
|
||||
ynh_exec_warn_less systemd-run --wait --uid="$app" --gid="$app" \
|
||||
ynh_hide_warnings systemd-run --wait --uid="$app" --gid="$app" \
|
||||
--property=RootDirectory="$install_dir"/seafile_image \
|
||||
--property="BindPaths=$systemd_seafile_bind_mount" \
|
||||
$@
|
||||
|
@ -76,14 +76,15 @@ set_permission() {
|
|||
|
||||
clean_url_in_db_config() {
|
||||
sql_request='DELETE FROM `constance_config` WHERE `constance_key`= "SERVICE_URL"'
|
||||
ynh_mysql_execute_as_root --sql="$sql_request" --database=seahubdb
|
||||
ynh_mysql_db_shell <<< "$sql_request" --database=seahubdb
|
||||
sql_request='DELETE FROM `constance_config` WHERE `constance_key`= "FILE_SERVER_ROOT"'
|
||||
ynh_mysql_execute_as_root --sql="$sql_request" --database=seahubdb
|
||||
ynh_mysql_db_shell <<< "$sql_request" --database=seahubdb
|
||||
}
|
||||
|
||||
ensure_vars_set() {
|
||||
# FIXMEhelpers2.1: maybe replace with: ynh_app_setting_set_default --key=jwt_private_key_notification_server --value=$(ynh_string_random -l 32)
|
||||
if [ -z "${jwt_private_key_notification_server:-}" ]; then
|
||||
jwt_private_key_notification_server=$(ynh_string_random -l 32)
|
||||
ynh_app_setting_set --app="$app" --key=jwt_private_key_notification_server --value="$jwt_private_key_notification_server"
|
||||
ynh_app_setting_set --key=jwt_private_key_notification_server --value="$jwt_private_key_notification_server"
|
||||
fi
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@ seafile_version=$(ynh_app_upstream_version)
|
|||
seafile_code="$install_dir/seafile_image/opt/seafile/seafile-server-$seafile_version"
|
||||
|
||||
if systemctl is-active seafile --quiet || systemctl is-active seahub --quiet; then
|
||||
ynh_print_warn --message="It's hightly recommended to make your backup when the service is stopped. Please stop seafile service and seahub service with this command before to run the backup 'systemctl stop seafile.service seahub.service'"
|
||||
ynh_print_warn "It's hightly recommended to make your backup when the service is stopped. Please stop seafile service and seahub service with this command before to run the backup 'systemctl stop seafile.service seahub.service'"
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
|
@ -23,24 +23,25 @@ fi
|
|||
#=================================================
|
||||
|
||||
# # Backup app files
|
||||
ynh_print_info --message="Backing up code..."
|
||||
ynh_backup --src_path="$install_dir"
|
||||
ynh_print_info --message="Backing up user data..."
|
||||
ynh_backup --src_path="$data_dir" --dest_path="data" --is_big=1
|
||||
ynh_print_info --message="Backing up configuration..."
|
||||
ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/${app}.conf"
|
||||
ynh_backup --src_path=/etc/systemd/system/seafile.service
|
||||
ynh_backup --src_path=/etc/systemd/system/seahub.service
|
||||
ynh_backup --src_path=/etc/fail2ban/jail.d/"$app".conf
|
||||
ynh_backup --src_path=/etc/fail2ban/filter.d/"$app".conf
|
||||
ynh_print_info "Backing up code..."
|
||||
ynh_backup "$install_dir"
|
||||
ynh_print_info "Backing up user data..."
|
||||
ynh_backup "$data_dir" --dest_path="data"
|
||||
|
||||
ynh_print_info "Backing up configuration..."
|
||||
ynh_backup "/etc/nginx/conf.d/$domain.d/${app}.conf"
|
||||
ynh_backup /etc/systemd/system/seafile.service
|
||||
ynh_backup /etc/systemd/system/seahub.service
|
||||
ynh_backup /etc/fail2ban/jail.d/"$app".conf
|
||||
ynh_backup /etc/fail2ban/filter.d/"$app".conf
|
||||
|
||||
# Backup logs
|
||||
ynh_backup --src_path="/var/log/$app"
|
||||
ynh_backup "/var/log/$app"
|
||||
|
||||
# Backup mysql
|
||||
ynh_print_info --message="Backing up database"
|
||||
ynh_mysql_dump_db --database="$db_name" > "${YNH_CWD}"/seafiledb.dmp
|
||||
ynh_print_info "Backing up database"
|
||||
ynh_mysql_dump_db > "${YNH_CWD}"/seafiledb.dmp
|
||||
ynh_mysql_dump_db --database=ccnetdb > "${YNH_CWD}"/ccnetdb.dmp
|
||||
ynh_mysql_dump_db --database=seahubdb > "${YNH_CWD}"/seahubdb.dmp
|
||||
|
||||
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)."
|
||||
|
|
|
@ -14,35 +14,33 @@ source /usr/share/yunohost/helpers
|
|||
seafile_version="$(ynh_app_upstream_version)"
|
||||
seafile_code="$install_dir/seafile_image/opt/seafile/seafile-server-$seafile_version"
|
||||
|
||||
#=================================================
|
||||
# STANDARD MODIFICATIONS
|
||||
#=================================================
|
||||
|
||||
ynh_script_progression --message="Updating NGINX web server configuration..." --weight=1
|
||||
ynh_change_url_nginx_config
|
||||
ynh_script_progression "Updating NGINX web server configuration..."
|
||||
ynh_config_change_url_nginx
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC MODIFICATIONS
|
||||
#=================================================
|
||||
|
||||
ynh_script_progression --message="Stoping services..."
|
||||
ynh_script_progression "Stoping services..."
|
||||
|
||||
# Stop service before any change
|
||||
ynh_systemd_action --service_name=seafile --action=stop
|
||||
ynh_systemd_action --service_name=seahub --action=stop
|
||||
ynh_systemctl --service=seafile --action=stop
|
||||
ynh_systemctl --service=seahub --action=stop
|
||||
sleep 2
|
||||
pkill -f seafile-controller || true
|
||||
pkill -f seaf-server || true
|
||||
pkill -f ccnet-server || true
|
||||
pkill -f seahub || true
|
||||
|
||||
ynh_script_progression --message="Updating seafile configuration..."
|
||||
ynh_script_progression "Updating seafile configuration..."
|
||||
|
||||
# Update Seafile Config
|
||||
ynh_add_config --jinja --template=seahub_settings.py --destination="$install_dir"/conf/seahub_settings.py
|
||||
ynh_add_config --template=ccnet.conf --destination="$install_dir"/conf/ccnet.conf
|
||||
ynh_add_config --template=gunicorn.conf.py --destination="$install_dir"/conf/gunicorn.conf.py
|
||||
ynh_add_config --template=seafdav.conf --destination="$install_dir"/conf/seafdav.conf
|
||||
ynh_config_add --jinja --template=seahub_settings.py --destination="$install_dir"/conf/seahub_settings.py
|
||||
ynh_config_add --template=ccnet.conf --destination="$install_dir"/conf/ccnet.conf
|
||||
ynh_config_add --template=gunicorn.conf.py --destination="$install_dir"/conf/gunicorn.conf.py
|
||||
ynh_config_add --template=seafdav.conf --destination="$install_dir"/conf/seafdav.conf
|
||||
|
||||
# Update permissions
|
||||
ynh_permission_url --permission=file_server --url="$domain"/seafhttp
|
||||
|
@ -55,9 +53,9 @@ clean_url_in_db_config
|
|||
sleep 2
|
||||
|
||||
# Reload services
|
||||
ynh_script_progression --message="Starting services..."
|
||||
ynh_systemd_action --service_name=seafile -l "spawned seaf-server, pid " -p /var/log/seafile/controller.log
|
||||
ynh_systemd_action --service_name=seahub -l "Started Seafile hub." -p "systemd"
|
||||
ynh_script_progression "Starting services..."
|
||||
ynh_systemctl --service=seafile -l "spawned seaf-server, pid " -p /var/log/seafile/controller.log
|
||||
ynh_systemctl --service=seahub -l "Started Seafile hub." -p "systemd"
|
||||
sleep 2
|
||||
|
||||
ynh_script_progression --message="Change of URL completed for $app" --time=--last
|
||||
ynh_script_progression "Change of URL completed for $app" --time=
|
||||
|
|
|
@ -17,11 +17,9 @@ seafile_code="$install_dir/seafile_image/opt/seafile/seafile-server-$seafile_ver
|
|||
|
||||
ensure_vars_set
|
||||
|
||||
#=================================================
|
||||
# STANDARD MODIFICATIONS
|
||||
#=================================================
|
||||
|
||||
ynh_script_progression --message="Creating base directory..."
|
||||
ynh_script_progression "Creating base directory..."
|
||||
|
||||
if [ -n "$(ls -A "$data_dir")" ]; then
|
||||
old_data_dir_path="${data_dir}_$(date '+%Y%m%d.%H%M%S')"
|
||||
|
@ -35,25 +33,25 @@ mkdir -p "$data_dir"/{seafile-data,seahub-data}
|
|||
mkdir -p "$install_dir"/{conf,ccnet}
|
||||
|
||||
# Download new version from sources
|
||||
ynh_script_progression --message="Installing sources files..." --weight=7
|
||||
ynh_script_progression "Installing sources files..."
|
||||
install_source
|
||||
|
||||
# init databases
|
||||
ynh_script_progression --message="Configuring MySQL database..."
|
||||
ynh_script_progression "Configuring MySQL database..."
|
||||
db_user=seafile
|
||||
ynh_''mysql_setup_db --db_user="$db_user" --db_name=ccnetdb --db_pwd="$db_pwd"
|
||||
ynh_''mysql_setup_db --db_user="$db_user" --db_name=seahubdb --db_pwd="$db_pwd"
|
||||
|
||||
ynh_script_progression --message="Configuring application..." --weight=3
|
||||
ynh_script_progression "Configuring application..."
|
||||
|
||||
# Run install script
|
||||
set_permission
|
||||
ynh_replace_special_string --match_string='seafile_config.seafile_dir = seafile_config.validate_seafile_dir(seafile_dir)' \
|
||||
--replace_string='seafile_config.seafile_dir = seafile_dir' \
|
||||
--target_file="$seafile_code/setup-seafile-mysql.py"
|
||||
ynh_replace_special_string --match_string="Utils.error('Ccnet config dir \\\"%s\\\" already exists.' % ccnet_config.ccnet_dir)" \
|
||||
--replace_string='patched = 1' \
|
||||
--target_file="$seafile_code/setup-seafile-mysql.py"
|
||||
ynh_replace_regex --match='seafile_config.seafile_dir = seafile_config.validate_seafile_dir(seafile_dir)' \
|
||||
--replace='seafile_config.seafile_dir = seafile_dir' \
|
||||
--file="$seafile_code/setup-seafile-mysql.py"
|
||||
ynh_replace_regex --match="Utils.error('Ccnet config dir \\\"%s\\\" already exists.' % ccnet_config.ccnet_dir)" \
|
||||
--replace='patched = 1' \
|
||||
--file="$seafile_code/setup-seafile-mysql.py"
|
||||
run_seafile_cmd bash "/opt/seafile/seafile-server-$seafile_version/setup-seafile-mysql.sh" auto \
|
||||
--server-name "$server_name" \
|
||||
--server-ip "$domain" \
|
||||
|
@ -69,79 +67,77 @@ run_seafile_cmd bash "/opt/seafile/seafile-server-$seafile_version/setup-seafile
|
|||
|
||||
# Retrive values from auto generated config file
|
||||
seahub_secret_key=$(grep -P 'SECRET_KEY\s*=\s*".+"' "$install_dir"/conf/seahub_settings.py | cut -d'"' -f2)
|
||||
ynh_app_setting_set --app="$app" --key=seahub_secret_key --value="$seahub_secret_key"
|
||||
ynh_app_setting_set --key=seahub_secret_key --value="$seahub_secret_key"
|
||||
|
||||
# Update seafile config files
|
||||
ynh_add_config --jinja --template=seahub_settings.py --destination="$install_dir"/conf/seahub_settings.py
|
||||
ynh_add_config --template=seafile.conf --destination="$install_dir"/conf/seafile.conf
|
||||
ynh_add_config --template=ccnet.conf --destination="$install_dir"/conf/ccnet.conf
|
||||
ynh_add_config --template=gunicorn.conf.py --destination="$install_dir"/conf/gunicorn.conf.py
|
||||
ynh_add_config --template=seafdav.conf --destination="$install_dir"/conf/seafdav.conf
|
||||
ynh_add_config --template=seafevents.conf --destination="$install_dir"/conf/seafevents.conf
|
||||
ynh_config_add --jinja --template=seahub_settings.py --destination="$install_dir"/conf/seahub_settings.py
|
||||
ynh_config_add --template=seafile.conf --destination="$install_dir"/conf/seafile.conf
|
||||
ynh_config_add --template=ccnet.conf --destination="$install_dir"/conf/ccnet.conf
|
||||
ynh_config_add --template=gunicorn.conf.py --destination="$install_dir"/conf/gunicorn.conf.py
|
||||
ynh_config_add --template=seafdav.conf --destination="$install_dir"/conf/seafdav.conf
|
||||
ynh_config_add --template=seafevents.conf --destination="$install_dir"/conf/seafevents.conf
|
||||
|
||||
# Configure admin info
|
||||
# It will be used the first start
|
||||
admin_email=$(ynh_user_get_info --username="$admin" --key='mail')
|
||||
cp ../conf/create_admin.json $install_dir/conf/admin.txt
|
||||
ynh_replace_string --match_string=__ADMIN__ --replace_string="$admin_email" --target_file=$install_dir/conf/admin.txt
|
||||
ynh_replace_special_string --match_string=__PASSWORD__ --replace_string="$admin_password" --target_file=$install_dir/conf/admin.txt
|
||||
ynh_replace --match=__ADMIN__ --replace="$admin_email" --file=$install_dir/conf/admin.txt
|
||||
ynh_replace_regex --match=__PASSWORD__ --replace="$admin_password" --file=$install_dir/conf/admin.txt
|
||||
|
||||
# Use symlink to store data
|
||||
if [ -e "$install_dir"/seafile-data ]; then
|
||||
mv -t "$data_dir"/seafile-data "$install_dir"/seafile-data/*
|
||||
ynh_secure_remove --file="$install_dir"/seafile-data
|
||||
ynh_safe_rm "$install_dir"/seafile-data
|
||||
fi
|
||||
if [ -e "$install_dir"/seahub-data ]; then
|
||||
mv -t "$data_dir"/seahub-data "$install_dir"/seahub-data/*
|
||||
ynh_secure_remove --file="$install_dir"/seahub-data
|
||||
ynh_safe_rm "$install_dir"/seahub-data
|
||||
fi
|
||||
if [ -e "$install_dir"/logs ]; then
|
||||
mv -t /var/log/"$app" "$install_dir"/logs/*
|
||||
ynh_secure_remove --file="$install_dir"/logs
|
||||
ynh_safe_rm "$install_dir"/logs
|
||||
fi
|
||||
ln -s "$data_dir"/seafile-data "$install_dir"/seafile-data
|
||||
ln -s "$data_dir"/seahub-data "$install_dir"/seahub-data
|
||||
ln -s /var/log/"$app" "$install_dir"/logs
|
||||
|
||||
# Fix local warning
|
||||
ynh_replace_string --match_string=en_US.UTF-8 --replace_string="${LANG:-'en_US.UTF-8'}" --target_file="$seafile_code/seahub.sh"
|
||||
ynh_replace --match=en_US.UTF-8 --replace="${LANG:-'en_US.UTF-8'}" --file="$seafile_code/seahub.sh"
|
||||
|
||||
# Add Seafile Server to startup
|
||||
ynh_script_progression --message="Configuring a systemd service..."
|
||||
ynh_add_systemd_config --service=seafile --template=seafile.service
|
||||
ynh_add_systemd_config --service=seahub --template=seahub.service
|
||||
ynh_script_progression "Configuring $app's systemd service..."
|
||||
ynh_config_add_systemd --service=seafile --template=seafile.service
|
||||
ynh_config_add_systemd --service=seahub --template=seahub.service
|
||||
|
||||
# register yunohost service
|
||||
yunohost service add seafile --description 'Main service for seafile server.'
|
||||
yunohost service add seahub --description 'Seafile server web interface.'
|
||||
|
||||
# Config nginx
|
||||
ynh_script_progression --message="Configuring nginx..."
|
||||
ynh_add_nginx_config
|
||||
ynh_script_progression "Configuring nginx..."
|
||||
ynh_config_add_nginx
|
||||
|
||||
# Add logrotate
|
||||
ynh_script_progression --message="Configuring log rotation..."
|
||||
ynh_use_logrotate --logfile=/var/log/"$app"
|
||||
ynh_script_progression "Configuring log rotation..."
|
||||
ynh_config_add_logrotate /var/log/"$app"
|
||||
|
||||
# Add fail2ban
|
||||
ynh_script_progression --message="Configuring fail2ban..."
|
||||
ynh_add_fail2ban_config --use_template
|
||||
ynh_script_progression "Configuring fail2ban..."
|
||||
ynh_config_add_fail2ban
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALIZATION
|
||||
#=================================================
|
||||
|
||||
# Set all permissions
|
||||
ynh_script_progression --message="Protecting directory..."
|
||||
ynh_script_progression "Protecting directory..."
|
||||
set_permission
|
||||
|
||||
# Start service
|
||||
sleep 3
|
||||
|
||||
ynh_script_progression --message="Starting seafile services..."
|
||||
ynh_systemd_action --service_name=seafile -l "spawned seaf-server, pid " -p /var/log/seafile/controller.log
|
||||
ynh_script_progression "Starting seafile services..."
|
||||
ynh_systemctl --service=seafile -l "spawned seaf-server, pid " -p /var/log/seafile/controller.log
|
||||
sleep 2
|
||||
ynh_systemd_action --service_name=seahub -l "Started Seafile hub." -p "systemd"
|
||||
ynh_systemctl --service=seahub -l "Started Seafile hub." -p "systemd"
|
||||
sleep 2
|
||||
|
||||
ynh_script_progression --message="Installation of $app completed" --last
|
||||
ynh_script_progression "Installation of $app completed"
|
||||
|
|
|
@ -18,11 +18,11 @@ seafile_code="$install_dir/seafile_image/opt/seafile/seafile-server-$seafile_ver
|
|||
# STANDARD REMOVE
|
||||
#=================================================
|
||||
|
||||
ynh_script_progression --message="Stoping services..."
|
||||
ynh_script_progression "Stoping services..."
|
||||
|
||||
# Stop all services
|
||||
ynh_systemd_action --service_name=seafile --action=stop
|
||||
ynh_systemd_action --service_name=seahub --action=stop
|
||||
ynh_systemctl --service=seafile --action=stop
|
||||
ynh_systemctl --service=seahub --action=stop
|
||||
|
||||
# Force to kill all process in case of a process is not stoped cleanly
|
||||
pkill -f seafile-controller || true
|
||||
|
@ -30,35 +30,36 @@ pkill -f seaf-server || true
|
|||
pkill -f ccnet-server || true
|
||||
pkill -f seahub || true
|
||||
|
||||
ynh_script_progression --message="Removing code..."
|
||||
ynh_secure_remove --file=/var/www/"$app"
|
||||
ynh_secure_remove --file=/opt/yunohost/"$app"
|
||||
ynh_script_progression "Removing code..."
|
||||
ynh_safe_rm /var/www/"$app"
|
||||
ynh_safe_rm /opt/yunohost/"$app"
|
||||
|
||||
# Remove databases
|
||||
ynh_script_progression --message="Removing databases..."
|
||||
ynh_script_progression "Removing databases..."
|
||||
db_helper=ynh_"mysql"_remove_db
|
||||
$db_helper --db_name ccnetdb --db_user seafile
|
||||
$db_helper --db_name seahubdb --db_user seafile
|
||||
|
||||
# Remove systemd service
|
||||
ynh_script_progression --message="Removing systemd units..."
|
||||
ynh_remove_systemd_config --service=seafile
|
||||
ynh_remove_systemd_config --service=seahub
|
||||
ynh_script_progression "Removing systemd units..."
|
||||
ynh_config_remove_systemdseafile
|
||||
ynh_config_remove_systemdseahub
|
||||
|
||||
# Remove nginx config
|
||||
ynh_script_progression --message="Removing nginx configuration..."
|
||||
ynh_remove_nginx_config
|
||||
ynh_script_progression "Removing nginx configuration..."
|
||||
ynh_config_remove_nginx
|
||||
|
||||
# Remove logrotate
|
||||
ynh_remove_logrotate
|
||||
ynh_config_remove_logrotate
|
||||
|
||||
# Remove the dedicated fail2ban config
|
||||
ynh_script_progression --message="Removing fail2ban configuration..."
|
||||
ynh_remove_fail2ban_config
|
||||
ynh_script_progression "Removing fail2ban configuration..."
|
||||
ynh_config_remove_fail2ban
|
||||
|
||||
ynh_script_progression --message="Removing seafile service..."
|
||||
ynh_script_progression "Removing seafile service..."
|
||||
yunohost service remove seafile
|
||||
yunohost service remove seahub
|
||||
|
||||
ynh_script_progression --message="Removal of $app completed" --last
|
||||
ynh_script_progression "Removal of $app completed"
|
||||
|
||||
sleep 1
|
||||
|
|
|
@ -14,18 +14,17 @@ source /usr/share/yunohost/helpers
|
|||
seafile_version="$(ynh_app_upstream_version)"
|
||||
seafile_code="$install_dir/seafile_image/opt/seafile/seafile-server-$seafile_version"
|
||||
|
||||
ynh_script_progression --message="Loading settings..."
|
||||
ynh_script_progression "Loading settings..."
|
||||
|
||||
#=================================================
|
||||
# STANDARD RESTORATION STEPS
|
||||
#=================================================
|
||||
|
||||
# Restore all config and data
|
||||
ynh_script_progression --message="Restoring files..." --weight=10
|
||||
ynh_restore
|
||||
|
||||
ynh_script_progression "Restoring files..."
|
||||
ynh_restore_everything
|
||||
# Restore mysql dump
|
||||
ynh_script_progression --message="Restoring database..." --weight=3
|
||||
ynh_script_progression "Restoring database..."
|
||||
db_helper=ynh_"mysql"_setup_db
|
||||
$db_helper --db_user "$db_user" --db_name ccnetdb --db_pwd "$db_pwd"
|
||||
$db_helper --db_user "$db_user" --db_name seahubdb --db_pwd "$db_pwd"
|
||||
|
@ -33,45 +32,43 @@ su -c "mysql -u ${app} -p$db_pwd $db_name < ${YNH_CWD}/seafiledb.dmp"
|
|||
su -c "mysql -u ${app} -p$db_pwd ccnetdb < ${YNH_CWD}/ccnetdb.dmp"
|
||||
su -c "mysql -u ${app} -p$db_pwd seahubdb < ${YNH_CWD}/seahubdb.dmp"
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALIZATION
|
||||
#=================================================
|
||||
|
||||
# Add logrotate
|
||||
ynh_script_progression --message="Configuring log rotation..."
|
||||
ynh_script_progression "Configuring log rotation..."
|
||||
mkdir -p /var/log/"$app"
|
||||
ynh_use_logrotate --logfile="$install_dir"/logs
|
||||
ynh_config_add_logrotate "$install_dir"/logs
|
||||
|
||||
# Set all permissions
|
||||
ynh_script_progression --message="Protecting directory..."
|
||||
ynh_script_progression "Protecting directory..."
|
||||
set_permission
|
||||
|
||||
# Enable service and start seafile
|
||||
ynh_script_progression --message="Reconfiguring application..."
|
||||
ynh_script_progression "Reconfiguring application..."
|
||||
systemctl daemon-reload
|
||||
systemctl enable seafile --quiet
|
||||
systemctl enable seahub --quiet
|
||||
|
||||
# Add Seafile to YunoHost's monitored services
|
||||
ynh_script_progression --message="Register seafile service..."
|
||||
ynh_script_progression "Register seafile service..."
|
||||
yunohost service add seafile --description 'Main service for seafile server.'
|
||||
yunohost service add seahub --description 'Seafile server web interface.'
|
||||
|
||||
ynh_script_progression --message="Reloading services..."
|
||||
ynh_script_progression "Reloading services..."
|
||||
|
||||
# Reload nginx
|
||||
systemctl reload nginx.service
|
||||
|
||||
# Reload fail2ban
|
||||
ynh_systemd_action --service_name=fail2ban --action=reload
|
||||
ynh_systemctl --service=fail2ban --action=reload
|
||||
|
||||
# Avoid the current effect
|
||||
sleep 5
|
||||
|
||||
# Restart service
|
||||
ynh_script_progression --message="Starting seafile services..." --weight=3
|
||||
ynh_systemd_action --service_name=seafile -l "spawned seaf-server, pid " -p /var/log/seafile/controller.log
|
||||
ynh_systemd_action --service_name=seahub -l "Started Seafile hub." -p "systemd"
|
||||
ynh_script_progression "Starting seafile services..."
|
||||
ynh_systemctl --service=seafile -l "spawned seaf-server, pid " -p /var/log/seafile/controller.log
|
||||
ynh_systemctl --service=seahub -l "Started Seafile hub." -p "systemd"
|
||||
sleep 2
|
||||
|
||||
ynh_script_progression --message="Restoration completed for $app" --last
|
||||
ynh_script_progression "Restoration completed for $app"
|
||||
|
|
|
@ -23,10 +23,10 @@ if [ "$YNH_APP_CURRENT_VERSION" == '-' ] || ynh_compare_current_package_version
|
|||
ynh_die "Upgrade from this version not supported"
|
||||
fi
|
||||
|
||||
ynh_script_progression --message="Stoping services..."
|
||||
ynh_script_progression "Stoping services..."
|
||||
|
||||
ynh_systemd_action --service_name=seafile --action=stop
|
||||
ynh_systemd_action --service_name=seahub --action=stop
|
||||
ynh_systemctl --service=seafile --action=stop
|
||||
ynh_systemctl --service=seahub --action=stop
|
||||
sleep 5
|
||||
pkill -f seafile-controller || true
|
||||
pkill -f seaf-server || true
|
||||
|
@ -42,14 +42,15 @@ if mysqlshow | grep -q seafiledb; then
|
|||
$mysqlconn -e "RENAME TABLE seafiledb.$name to $db_name.$name";
|
||||
done;
|
||||
$mysqlconn -e "DROP DATABASE seafiledb"
|
||||
ynh_replace_string --match_string='db_name = seafiledb' --replace_string='db_name = seafile' --target_file="$install_dir"/conf/seafile.conf
|
||||
ynh_replace --match='db_name = seafiledb' --replace='db_name = seafile' --file="$install_dir"/conf/seafile.conf
|
||||
sed -i "s|password\s*=\s*.*^|password = $db_pwd|g" "$install_dir"/conf/seafile.conf
|
||||
fi
|
||||
|
||||
# Set missing settings
|
||||
# FIXMEhelpers2.1: maybe replace with: ynh_app_setting_set_default --key=seahub_secret_key --value="$(grep -P 'SECRET_KEY\s*=\s*".+"' "$install_dir"/conf/seahub_settings.py | cut -d'"' -f2)"
|
||||
if [ -z "${seahub_secret_key:-}" ]; then
|
||||
seahub_secret_key="$(grep -P 'SECRET_KEY\s*=\s*".+"' "$install_dir"/conf/seahub_settings.py | cut -d'"' -f2)"
|
||||
ynh_app_setting_set --app="$app" --key=seahub_secret_key --value="$seahub_secret_key"
|
||||
ynh_app_setting_set --key=seahub_secret_key --value="$seahub_secret_key"
|
||||
fi
|
||||
|
||||
#
|
||||
|
@ -97,15 +98,15 @@ if [ ! -L "$install_dir"/logs ]; then
|
|||
ln -s /var/log/"${app}" "$install_dir"/logs
|
||||
fi
|
||||
|
||||
ynh_script_progression --message="Upgrading source files..." --weight=6
|
||||
ynh_script_progression "Upgrading source files..."
|
||||
|
||||
# Download new version from sources
|
||||
ynh_script_progression --message="Installing sources files..." --weight=7
|
||||
ynh_script_progression "Installing sources files..."
|
||||
if [ "$YNH_APP_UPGRADE_TYPE" == UPGRADE_APP ]; then
|
||||
install_source
|
||||
fi
|
||||
|
||||
ynh_script_progression --message="Configuring application..."
|
||||
ynh_script_progression "Configuring application..."
|
||||
|
||||
# permission to execute update script and expect helper
|
||||
set_permission
|
||||
|
@ -128,7 +129,7 @@ case "$installed_version" in
|
|||
run_seafile_cmd "/opt/seafile/seafile-server-$seafile_version/seahub.sh" python-env python3 "/opt/seafile/seafile-server-$seafile_version/seahub/manage.py" migrate_file_comment
|
||||
|
||||
# Update seafile by script
|
||||
ynh_replace_string --match_string='read dummy' --replace_string='# patched' --target_file="$seafile_code/upgrade/upgrade_7.0_7.1.sh"
|
||||
ynh_replace --match='read dummy' --replace='# patched' --file="$seafile_code/upgrade/upgrade_7.0_7.1.sh"
|
||||
run_seafile_cmd "/opt/seafile/seafile-server-$seafile_version/upgrade/upgrade_7.0_7.1.sh"
|
||||
|
||||
# Fix seafile data link. Look like that the upgrade script of seafile don't always work correctly
|
||||
|
@ -139,90 +140,86 @@ case "$installed_version" in
|
|||
ln -s "$data_dir" "$install_dir"/seafile-data
|
||||
;&
|
||||
"7.1."* )
|
||||
ynh_replace_string --match_string='read dummy' --replace_string='# patched' --target_file="$seafile_code/upgrade/upgrade_8.0_9.0.sh"
|
||||
ynh_replace --match='read dummy' --replace='# patched' --file="$seafile_code/upgrade/upgrade_8.0_9.0.sh"
|
||||
run_seafile_cmd "/opt/seafile/seafile-server-$seafile_version/upgrade/upgrade_8.0_9.0.sh"
|
||||
;&
|
||||
"8.0."* )
|
||||
ynh_replace_string --match_string='read dummy' --replace_string='# patched' --target_file="$seafile_code/upgrade/upgrade_7.1_8.0.sh"
|
||||
ynh_replace --match='read dummy' --replace='# patched' --file="$seafile_code/upgrade/upgrade_7.1_8.0.sh"
|
||||
run_seafile_cmd "/opt/seafile/seafile-server-$seafile_version/upgrade/upgrade_7.1_8.0.sh"
|
||||
;&
|
||||
"9."* )
|
||||
ynh_replace_string --match_string='read dummy' --replace_string='# patched' --target_file="$seafile_code/upgrade/upgrade_8.0_9.0.sh"
|
||||
ynh_replace --match='read dummy' --replace='# patched' --file="$seafile_code/upgrade/upgrade_8.0_9.0.sh"
|
||||
run_seafile_cmd "/opt/seafile/seafile-server-$seafile_version/upgrade/upgrade_8.0_9.0.sh"
|
||||
;&
|
||||
"10."* )
|
||||
ynh_replace_string --match_string='read dummy' --replace_string='# patched' --target_file="$seafile_code/upgrade/upgrade_9.0_10.0.sh"
|
||||
ynh_replace --match='read dummy' --replace='# patched' --file="$seafile_code/upgrade/upgrade_9.0_10.0.sh"
|
||||
run_seafile_cmd "/opt/seafile/seafile-server-$seafile_version/upgrade/upgrade_9.0_10.0.sh"
|
||||
run_seafile_cmd "/opt/seafile/seafile-server-$seafile_version/seahub.sh" python-env python3 "/opt/seafile/seafile-server-$seafile_version/migrate_ldapusers.py"
|
||||
;&
|
||||
esac
|
||||
|
||||
ynh_replace_string --match_string='read dummy' --replace_string='# patched' --target_file="$seafile_code/upgrade/minor-upgrade.sh"
|
||||
ynh_replace --match='read dummy' --replace='# patched' --file="$seafile_code/upgrade/minor-upgrade.sh"
|
||||
run_seafile_cmd "/opt/seafile/seafile-server-$seafile_version/upgrade/minor-upgrade.sh"
|
||||
|
||||
# Clean url in config in DB
|
||||
clean_url_in_db_config
|
||||
|
||||
# Update seafile config files
|
||||
ynh_add_config --jinja --template=seahub_settings.py --destination="$install_dir"/conf/seahub_settings.py
|
||||
ynh_add_config --template=seafile.conf --destination="$install_dir"/conf/seafile.conf
|
||||
ynh_add_config --template=ccnet.conf --destination="$install_dir"/conf/ccnet.conf
|
||||
ynh_add_config --template=gunicorn.conf.py --destination="$install_dir"/conf/gunicorn.conf.py
|
||||
ynh_add_config --template=seafdav.conf --destination="$install_dir"/conf/seafdav.conf
|
||||
ynh_add_config --template=seafevents.conf --destination="$install_dir"/conf/seafevents.conf
|
||||
ynh_config_add --jinja --template=seahub_settings.py --destination="$install_dir"/conf/seahub_settings.py
|
||||
ynh_config_add --template=seafile.conf --destination="$install_dir"/conf/seafile.conf
|
||||
ynh_config_add --template=ccnet.conf --destination="$install_dir"/conf/ccnet.conf
|
||||
ynh_config_add --template=gunicorn.conf.py --destination="$install_dir"/conf/gunicorn.conf.py
|
||||
ynh_config_add --template=seafdav.conf --destination="$install_dir"/conf/seafdav.conf
|
||||
ynh_config_add --template=seafevents.conf --destination="$install_dir"/conf/seafevents.conf
|
||||
|
||||
# Fix local warning
|
||||
ynh_replace_string --match_string=en_US.UTF-8 --replace_string="${LANG:-'en_US.UTF-8'}" --target_file="$seafile_code/seahub.sh"
|
||||
ynh_replace --match=en_US.UTF-8 --replace="${LANG:-'en_US.UTF-8'}" --file="$seafile_code/seahub.sh"
|
||||
|
||||
#=================================================
|
||||
# STANDARD UPGRADE STEPS
|
||||
#=================================================
|
||||
|
||||
# Config nginx
|
||||
ynh_add_nginx_config 'seahub_port fileserver_port webdav_port'
|
||||
ynh_config_add_nginx 'seahub_port fileserver_port webdav_port'
|
||||
|
||||
# Add Seafile Server to startup
|
||||
ynh_script_progression --message="Updating systemd units..."
|
||||
ynh_add_systemd_config --service=seafile --template=seafile.service
|
||||
ynh_add_systemd_config --service=seahub --template=seahub.service
|
||||
ynh_script_progression "Updating systemd units..."
|
||||
ynh_config_add_systemd --service=seafile --template=seafile.service
|
||||
ynh_config_add_systemd --service=seahub --template=seahub.service
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALIZATION
|
||||
#=================================================
|
||||
|
||||
# Set all permissions
|
||||
ynh_script_progression --message="Protecting directory..."
|
||||
ynh_script_progression "Protecting directory..."
|
||||
set_permission
|
||||
|
||||
# Add logrotate
|
||||
ynh_script_progression --message="Configuring log rotation..."
|
||||
ynh_use_logrotate --logfile=/var/log/"$app" --nonappend
|
||||
ynh_script_progression "Configuring log rotation..."
|
||||
ynh_config_add_logrotate /var/log/"$app"
|
||||
|
||||
# Add fail2ban
|
||||
ynh_script_progression --message="Configuring fail2ban..." --weight=10
|
||||
ynh_add_fail2ban_config --use_template
|
||||
ynh_script_progression "Configuring fail2ban..."
|
||||
ynh_config_add_fail2ban
|
||||
|
||||
# register yunohost service
|
||||
ynh_script_progression --message="Register seafile service..."
|
||||
ynh_script_progression "Register seafile service..."
|
||||
yunohost service add seafile --description 'Main service for seafile server.'
|
||||
yunohost service add seahub --description 'Seafile server web interface.'
|
||||
|
||||
# delete seafile cache
|
||||
|
||||
# restart seafile server
|
||||
ynh_script_progression --message="Starting seafile services..." --weight=3
|
||||
ynh_script_progression "Starting seafile services..."
|
||||
sleep 5
|
||||
ynh_systemd_action --service_name=memcached.service -p "systemd"
|
||||
ynh_systemd_action --service_name=seafile -l "spawned seaf-server, pid " -p /var/log/seafile/controller.log
|
||||
ynh_systemd_action --service_name=seahub -l "Started Seafile hub." -p "systemd"
|
||||
ynh_systemctl --service=memcached.service -p "systemd"
|
||||
ynh_systemctl --service=seafile -l "spawned seaf-server, pid " -p /var/log/seafile/controller.log
|
||||
ynh_systemctl --service=seahub -l "Started Seafile hub." -p "systemd"
|
||||
sleep 2
|
||||
|
||||
# remove old version files
|
||||
ynh_script_progression --message="Cleaning system and updating settings..."
|
||||
ynh_script_progression "Cleaning system and updating settings..."
|
||||
for f in "$install_dir"/seafile-server-*;do
|
||||
if [[ ! "$f" =~ ${seafile_version//./\\.}|latest ]]; then
|
||||
ynh_secure_remove --file="$f"
|
||||
ynh_safe_rm "$f"
|
||||
fi
|
||||
done
|
||||
|
||||
ynh_script_progression --message="Upgrade of $app completed" --last
|
||||
ynh_script_progression "Upgrade of $app completed"
|
||||
|
|
Loading…
Reference in a new issue