#!/bin/bash #================================================= # GENERIC START #================================================= # IMPORT GENERIC HELPERS #================================================= source _common.sh source /usr/share/yunohost/helpers #================================================= # RETRIEVE ARGUMENTS FROM THE MANIFEST #================================================= #storage_quota="20gb" #ynh_app_setting_set --app=$app --key=storage_quota --value=$storage_quota #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= ynh_script_progression --message="Setting up source files..." --weight=1 # Download, check integrity, uncompress and patch the source from app.src ynh_setup_source --dest_dir="$install_dir" ynh_setup_source --dest_dir="$install_dir" --source_id="xftp" mkdir -p /etc/opt/simplex-xftp /etc/opt/simplex /var/opt/simplex-xftp /var/opt/simplex chown -R $app:$app /etc/opt/simplex-xftp /etc/opt/simplex /var/opt/simplex-xftp /var/opt/simplex chmod -R o-rwx "$install_dir" chown -R $app:$app "$install_dir" chmod +x $install_dir/smp-server chmod +x $install_dir/xftp-server #================================================= # SPECIFIC SETUP #================================================= public_ip4="$(curl -s ip.yunohost.org)" || true ynh_app_setting_set --app=$app --key=public_ip4 --value=$public_ip4 pushd "$install_dir" ./smp-server init --no-password --ip $public_ip4 --store-log --yes ./xftp-server init --ip $public_ip4 --quota '20gb' --store-log --path $data_dir popd fingerprint=$(cat /etc/opt/simplex/fingerprint) ynh_app_setting_set --app=$app --key=fingerprint --value=$fingerprint xftp_fingerprint=$(cat /etc/opt/simplex-xftp/fingerprint) ynh_app_setting_set --app=$app --key=xftp_fingerprint --value=$xftp_fingerprint ynh_replace_string --match_string="port: 443" --replace_string="port: $port_xftp" --target_file="/etc/opt/simplex-xftp/file-server.ini" chown -R $app:$app "/etc/opt/simplex" chown -R $app:$app "/etc/opt/simplex-xftp" #================================================= # ADD A CONFIGURATION #================================================= #ynh_script_progression --message="Adding a configuration file..." --weight=1 #ynh_add_config --template="file-server.ini" --destination="/etc/opt/simplex-xftp/file-server.ini" #chmod 400 "/etc/opt/simplex-xftp/file-server.ini" #chown $app:$app "/etc/opt/simplex-xftp/file-server.ini" #================================================= # SYSTEM CONFIGURATION #================================================= ynh_script_progression --message="Adding system configurations related to $app..." --weight=6 # Create a dedicated systemd config ynh_add_systemd_config ynh_add_systemd_config --service=xftp --template=../conf/xftp.systemd.service yunohost service add $app --description="Messaging platform" --log="/var/log/$app/$app.log" --needs_exposed_ports="$port" yunohost service add xftp --description="Messaging platform" --log="/var/log/$app/$app.log" --needs_exposed_ports="$port_xftp" #================================================= # START SYSTEMD SERVICE #================================================= ynh_script_progression --message="Starting a systemd service..." --weight=1 # Start a systemd service ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" ynh_systemd_action --service_name="xftp" --action="start" --log_path="systemd" #================================================= # END OF SCRIPT #================================================= ynh_script_progression --message="Installation of $app completed" --last