#!/bin/bash #================================================= # GENERIC START #================================================= # IMPORT GENERIC HELPERS #================================================= # 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 --message="Restoring the app main directory..." --weight=1 ynh_restore_file --origin_path="$install_dir" chmod -R o-rwx "$install_dir" chown -R $app:www-data "$install_dir" #================================================= # RESTORE THE DATA DIRECTORY #================================================= ynh_script_progression --message="Restoring the data directory..." --weight=1 ynh_restore_file --origin_path="$data_dir" --not_mandatory chown -R $app:www-data "$data_dir" #================================================= # RESTORE THE NGINX CONFIGURATION #================================================= ynh_script_progression --message="Restoring the NGINX web server configuration..." --weight=1 ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" #================================================= # ENABLE "TRANSCODE" #================================================= ynh_script_progression --message="Enabling transcode..." --weight=1 ### 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 --message="Restoring various files..." --weight=1 ynh_restore_file --origin_path="/etc/default/$app" #================================================= # YUNOHOST MULTIMEDIA INTEGRATION #================================================= ynh_script_progression --message="Adding multimedia directories..." --weight=3 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 --message="Restoring the systemd configuration..." --weight=1 ynh_restore_file --origin_path="/etc/systemd/system/$app.service" systemctl enable $app.service --quiet ynh_restore_file --origin_path="/etc/logrotate.d/$app" yunohost service add $app --description="Airsonic daemon" --log="$install_dir/$app.log" #================================================= # START SYSTEMD SERVICE #================================================= ynh_script_progression --message="Starting a systemd service..." --weight=12 ynh_systemd_action --service_name=$app --action="start" --log_path="$install_dir/$app.log" --line_match="Started Application in" ynh_systemd_action --service_name=nginx --action=reload #================================================= # END OF SCRIPT #================================================= ynh_script_progression --message="Restoration completed for $app" --last