mirror of
https://github.com/YunoHost-Apps/airsonic_ynh.git
synced 2024-09-03 18:06:14 +02:00
96 lines
3.7 KiB
Bash
96 lines
3.7 KiB
Bash
#!/bin/bash
|
|
|
|
# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
|
|
source ../settings/scripts/_common.sh
|
|
source /usr/share/yunohost/helpers
|
|
|
|
#=================================================
|
|
# RESTORE THE APP MAIN DIR
|
|
#=================================================
|
|
ynh_script_progression "Restoring the app main directory..."
|
|
|
|
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 DATA DIRECTORY
|
|
#=================================================
|
|
ynh_script_progression "Restoring the data directory..."
|
|
|
|
ynh_restore "$data_dir"
|
|
|
|
chown -R $app:www-data "$data_dir"
|
|
|
|
#=================================================
|
|
# RESTORE THE NGINX CONFIGURATION
|
|
#=================================================
|
|
ynh_script_progression "Restoring the NGINX web server configuration..."
|
|
|
|
ynh_restore "/etc/nginx/conf.d/$domain.d/$app.conf"
|
|
|
|
#=================================================
|
|
# ENABLE "TRANSCODE"
|
|
#=================================================
|
|
ynh_script_progression "Enabling transcode..."
|
|
|
|
### For details, see https://airsonic.github.io/docs/transcode/
|
|
|
|
mkdir -p $install_dir/transcode
|
|
|
|
if [ -x /usr/bin/ffmpeg -a ! -e $install_dir/transcode/ffmpeg ]; then # Check if 'ffmpeg' is installed, executable and that the symlink doesn't exist
|
|
ln -s /usr/bin/ffmpeg $install_dir/transcode
|
|
fi
|
|
|
|
# FIXME Not sure if 'lame' is needed ?
|
|
if [ -x /usr/bin/lame -a ! -e $install_dir/transcode/lame ]; then # Check if 'lame' is installed, executable and that the symlink doesn't exist
|
|
ln -s /usr/bin/lame $install_dir/transcode
|
|
fi
|
|
|
|
# Ensure links belong to the $app user
|
|
chown $app $install_dir/transcode
|
|
|
|
#=================================================
|
|
# RESTORE VARIOUS FILES
|
|
#=================================================
|
|
ynh_script_progression "Restoring various files..."
|
|
|
|
ynh_restore "/etc/default/$app"
|
|
|
|
#=================================================
|
|
# YUNOHOST MULTIMEDIA INTEGRATION
|
|
#=================================================
|
|
ynh_script_progression "Adding multimedia directories..."
|
|
|
|
ynh_multimedia_build_main_dir
|
|
ynh_multimedia_addfolder --source_dir="/home/yunohost.app/$app/Podcasts" --dest_dir="share/Podcasts"
|
|
ynh_multimedia_addfolder --source_dir="/home/yunohost.app/$app/Playlists" --dest_dir="share/Playlists"
|
|
# Allow airsonic to write into these directories
|
|
ynh_multimedia_addaccess --user_name=$app
|
|
|
|
#=================================================
|
|
# RESTORE SYSTEMD
|
|
#=================================================
|
|
ynh_script_progression "Restoring $app's systemd service..."
|
|
|
|
ynh_restore "/etc/systemd/system/$app.service"
|
|
systemctl enable $app.service --quiet
|
|
|
|
ynh_restore "/etc/logrotate.d/$app"
|
|
|
|
yunohost service add $app --description="Airsonic daemon" --log="$install_dir/$app.log"
|
|
|
|
#=================================================
|
|
# START SYSTEMD SERVICE
|
|
#=================================================
|
|
ynh_script_progression "Starting $app's systemd service..."
|
|
|
|
ynh_systemctl --service=$app --action="start" --log_path="$install_dir/$app.log" --wait_until="Started Application in"
|
|
|
|
ynh_systemctl --service=nginx --action=reload
|
|
|
|
#=================================================
|
|
# END OF SCRIPT
|
|
#=================================================
|
|
|
|
ynh_script_progression "Restoration completed for $app"
|