Skip to content

Commit

Permalink
Adapt all script for seafile 12
Browse files Browse the repository at this point in the history
  • Loading branch information
Josue-T committed Jan 11, 2025
1 parent 81606d5 commit 07fc4fa
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 23 deletions.
5 changes: 3 additions & 2 deletions scripts/backup
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
source ../settings/scripts/experimental_helper.sh
source ../settings/scripts/_common.sh

if systemctl is-active seafile --quiet || systemctl is-active seahub --quiet; then
if systemctl is-active "$app" --quiet || systemctl is-active seahub --quiet; then
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

Expand All @@ -24,8 +24,9 @@ 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/"$app".service
ynh_backup /etc/systemd/system/seahub.service
ynh_backup /etc/systemd/system/"$app"-notification.service
ynh_backup /etc/fail2ban/jail.d/"$app".conf
ynh_backup /etc/fail2ban/filter.d/"$app".conf

Expand Down
11 changes: 7 additions & 4 deletions scripts/change_url
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,12 @@ ynh_script_progression "Updating seafile configuration..."

# Update Seafile Config
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=seafile.conf --destination="$install_dir"/conf/seafile.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
ynh_config_add --jinja --template=seafile_env.j2 --destination="$install_dir"/seafile_env.conf
ynh_config_add --jinja --template=notification_server_env.j2 --destination="$install_dir"/notification_server_env.conf

# Update permissions
ynh_permission_url --permission=file_server --url="$domain"/seafhttp
Expand All @@ -48,9 +51,9 @@ sleep 2

# Reload services
ynh_script_progression "Starting services..."
ynh_systemctl --service=seafile --wait_until="spawned seaf-server, pid " --log_path=/var/log/seafile/controller.log
sleep 2
ynh_systemctl --service=seahub --wait_until="Seahub is started" --log_path="systemd"
ynh_systemctl --service="$app" --wait_until='spawned seaf-server, pid ' --log_path=/var/log/"$app"/controller.log
sleep 2
ynh_systemctl --service=seahub --wait_until='Seahub is started' --log_path="systemd"
ynh_systemctl --service="$app"-notification.service --wait_until="notification server started" --log_path=/var/log/"$app"/notification-server.log

ynh_script_progression "Change of URL completed for $app" --time=
13 changes: 7 additions & 6 deletions scripts/install
Original file line number Diff line number Diff line change
Expand Up @@ -106,13 +106,14 @@ ynh_replace --match=en_US.UTF-8 --replace="${LANG:-'en_US.UTF-8'}" --file="$seaf

# Add Seafile Server to startup
ynh_script_progression "Configuring $app's systemd service..."
ynh_config_add_systemd --service="$app" --template=seafile.service
ynh_config_add_systemd --service=seafile --template="$app".service
ynh_config_add_systemd --service=seahub --template=seahub.service
ynh_config_add_systemd --service="$app"-notification --template=seafile-notification.service
ynh_config_add_systemd --service=seafile-notification --template="$app"-notification.service

# register yunohost service
yunohost service add seafile --description 'Main service for seafile server.'
yunohost service add "$app" --description 'Main service for seafile server.'
yunohost service add seahub --description 'Seafile server web interface.'
yunohost service add "$app"-notification --description 'Seafile client notification server.'

# Config nginx
ynh_script_progression "Configuring nginx..."
Expand All @@ -136,9 +137,9 @@ set_permission
sleep 3

ynh_script_progression "Starting seafile services..."
ynh_systemctl --service=seafile --wait_until="spawned seaf-server, pid " --log_path=/var/log/seafile/controller.log
sleep 2
ynh_systemctl --service=seahub --wait_until="Seahub is started" --log_path="systemd"
ynh_systemctl --service="$app" --wait_until='spawned seaf-server, pid ' --log_path=/var/log/"$app"/controller.log
sleep 2
ynh_systemctl --service=seahub --wait_until='Seahub is started' --log_path="systemd"
ynh_systemctl --service="$app"-notification.service --wait_until="notification server started" --log_path=/var/log/"$app"/notification-server.log

ynh_script_progression "Installation of $app completed"
12 changes: 7 additions & 5 deletions scripts/restore
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,15 @@ set_permission
# Enable service and start seafile
ynh_script_progression "Reconfiguring application..."
systemctl daemon-reload
systemctl enable seafile --quiet
systemctl enable "$app" --quiet
systemctl enable seahub --quiet
systemctl enable "$app"-notification --quiet

# Add Seafile to YunoHost's monitored services
ynh_script_progression "Register seafile service..."
yunohost service add seafile --description 'Main service for seafile server.'
yunohost service add "$app" --description 'Main service for seafile server.'
yunohost service add seahub --description 'Seafile server web interface.'
yunohost service add "$app"-notification --description 'Seafile client notification server.'

ynh_script_progression "Reloading services..."

Expand All @@ -60,9 +62,9 @@ sleep 5

# Restart service
ynh_script_progression "Starting seafile services..."
ynh_systemctl --service=seafile --wait_until="spawned seaf-server, pid " --log_path=/var/log/seafile/controller.log
sleep 2
ynh_systemctl --service=seahub --wait_until="Seahub is started" --log_path="systemd"
ynh_systemctl --service="$app" --wait_until='spawned seaf-server, pid ' --log_path=/var/log/"$app"/controller.log
sleep 2
ynh_systemctl --service=seahub --wait_until='Seahub is started' --log_path="systemd"
ynh_systemctl --service="$app"-notification.service --wait_until="notification server started" --log_path=/var/log/"$app"/notification-server.log

ynh_script_progression "Restoration completed for $app"
16 changes: 10 additions & 6 deletions scripts/upgrade
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,8 @@ case "$installed_version" in
run_seafile_cmd "/opt/seafile/seafile-server-$seafile_version/seahub.sh" python-env python3 "/opt/seafile/seafile-server-$seafile_version/migrate_ldapusers.py"
;&
"11."* )
ynh_safe_rm "$install_dir"/conf/ccnet.conf

ynh_replace --match='read dummy' --replace='# patched' --file="$seafile_code/upgrade/upgrade_11.0_12.0.sh"
run_seafile_cmd "/opt/seafile/seafile-server-$seafile_version/upgrade/upgrade_11.0_12.0.sh"
;&
Expand Down Expand Up @@ -188,8 +190,9 @@ ynh_config_add_nginx 'seahub_port fileserver_port webdav_port'

# Add Seafile Server to startup
ynh_script_progression "Updating systemd units..."
ynh_config_add_systemd --service=seafile --template=seafile.service
ynh_config_add_systemd --service=seafile --template="$app".service
ynh_config_add_systemd --service=seahub --template=seahub.service
ynh_config_add_systemd --service=seafile-notification --template="$app"-notification.service

#=================================================

Expand All @@ -207,19 +210,20 @@ ynh_config_add_fail2ban

# register yunohost service
ynh_script_progression "Register seafile service..."
yunohost service add seafile --description 'Main service for seafile server.'
yunohost service add "$app" --description 'Main service for seafile server.'
yunohost service add seahub --description 'Seafile server web interface.'
yunohost service add "$app"-notification --description 'Seafile client notification server.'

# delete seafile cache

# restart seafile server
ynh_script_progression "Starting seafile services..."
sleep 5
ynh_systemctl --service=memcached.service -p "systemd"
ynh_systemctl --service=seafile --wait_until="spawned seaf-server, pid " --log_path=/var/log/seafile/controller.log
sleep 2
ynh_systemctl --service=seahub --wait_until="Seahub is started" --log_path="systemd"
sleep 5
ynh_systemctl --service="$app" --wait_until='spawned seaf-server, pid ' --log_path=/var/log/"$app"/controller.log
sleep 2
ynh_systemctl --service=seahub --wait_until='Seahub is started' --log_path="systemd"
ynh_systemctl --service="$app"-notification.service --wait_until="notification server started" --log_path=/var/log/"$app"/notification-server.log

# remove old version files
ynh_script_progression "Cleaning system and updating settings..."
Expand Down

0 comments on commit 07fc4fa

Please sign in to comment.