#!/bin/bash source _common.sh source /usr/share/yunohost/helpers #================================================= # RETRIEVE ARGUMENTS FROM THE MANIFEST #================================================= secret=$(ynh_string_random) email=$(ynh_user_get_info --username=$admin --key=mail) #================================================= # STORE SETTINGS FROM MANIFEST #================================================= ynh_app_setting_set --key=$secret --value="$secret" #================================================= # INSTALL DEPENDENCIES #================================================= ynh_script_progression "Installing dependencies..." # Install Nodejs ynh_nodejs_install #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= ynh_script_progression "Setting up source files..." # Download, check integrity, uncompress and patch the source from app.src git config --system --add safe.directory $install_dir git clone -b $nodebb_version https://github.com/NodeBB/NodeBB.git "$install_dir" --quiet chmod -R o-rwx "$install_dir" chown -R $app:www-data "$install_dir" #================================================= # NGINX CONFIGURATION #================================================= ynh_script_progression "Configuring NGINX web server..." # Create a dedicated NGINX config ynh_config_add_nginx #================================================= # SPECIFIC SETUP #================================================= # CONFIGURE NODEBB #================================================= ynh_script_progression "Configuring the app..." ynh_config_add --template="config.json" --destination="$install_dir/config.json" setup="{ \"admin:username\": \"$admin\", \"admin:password\": \"$password\", \"admin:password:confirm\": \"$password\", \"admin:email\": \"$email\" }" pushd $install_dir npm install npm@latest --location=global ynh_exec_as_app node_load_PATH npm install lodash --save ynh_exec_as_app node_load_PATH $install_dir/nodebb setup "${setup}" 2>/dev/null popd chmod 400 "$install_dir/config.json" chown $app:$app "$install_dir/config.json" #================================================= # SETUP SYSTEMD #================================================= ynh_script_progression "Configuring $app's systemd service..." ynh_config_add_systemd ynh_config_add_logrotate yunohost service add $app --description="Forum software" --log="/var/log/$app/$app.log" #================================================= # START SYSTEMD SERVICE #================================================= ynh_script_progression "Starting $app's systemd service..." # Start a systemd service ynh_systemctl --service=$app --action=restart --log_path="systemd" #================================================= # END OF SCRIPT #================================================= ynh_script_progression "Installation of $app completed"