mirror of
https://github.com/YunoHost-Apps/mongo-express_ynh.git
synced 2024-09-03 19:46:04 +02:00
92 lines
3.1 KiB
Bash
Executable file
92 lines
3.1 KiB
Bash
Executable file
#!/bin/bash
|
|
|
|
#=================================================
|
|
# GENERIC START
|
|
#=================================================
|
|
# IMPORT GENERIC HELPERS
|
|
#=================================================
|
|
|
|
source _common.sh
|
|
source /usr/share/yunohost/helpers
|
|
|
|
#=================================================
|
|
# INSTALL DEPENDENCIES
|
|
#=================================================
|
|
ynh_script_progression --message="Installing NodeJS & Yarn..." --weight=3
|
|
|
|
ynh_install_nodejs --nodejs_version="$nodejs_version"
|
|
|
|
# Install mongo server only if asked to
|
|
if [ "$mongo_version" != "None" ]; then
|
|
ynh_script_progression --message="Installing MongoDB..." --weight=3
|
|
ynh_install_mongo --mongo_version="$mongo_version"
|
|
else
|
|
# gives the mongo service name for the rest of installation
|
|
mongodb_servicename=mongod
|
|
fi
|
|
|
|
#=================================================
|
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
|
#=================================================
|
|
ynh_script_progression --message="Setting up source files..." --weight=1
|
|
|
|
# Download, check integrity, uncompress and patch the source from amd64.src
|
|
ynh_setup_source --dest_dir="$install_dir"
|
|
|
|
cp "$install_dir/config.default.js" "$install_dir/config.js"
|
|
|
|
chmod -R o-rwx "$install_dir"
|
|
chown -R "$app:$app" "$install_dir"
|
|
|
|
ynh_add_config --template=".env" --destination="$install_dir/.env"
|
|
chmod 400 "$install_dir/.env"
|
|
chown "$app:$app" "$install_dir/.env"
|
|
|
|
#=================================================
|
|
# BUILD NODEJS CODE
|
|
#=================================================
|
|
ynh_script_progression --message="Building NodeJS code ..." --weight=6
|
|
|
|
# Build using Yarn
|
|
pushd "$install_dir"
|
|
ynh_use_nodejs
|
|
# We must use npm to install yarn but without installing other dependencies as npm fails with them
|
|
if [ -f "package.json" ]; then
|
|
mv package.json package.json.mov
|
|
fi
|
|
_install_yarn
|
|
if [ -f "package.json.mov" ]; then
|
|
mv package.json.mov package.json
|
|
fi
|
|
ynh_exec_as "$app" "$ynh_node_load_PATH" "$ynh_yarn" install
|
|
ynh_exec_as "$app" "$ynh_node_load_PATH" "$ynh_npm" run build
|
|
popd
|
|
|
|
#=================================================
|
|
# SYSTEM CONFIGURATION
|
|
#=================================================
|
|
ynh_script_progression --message="Adding system configurations related to $app..." --weight=1
|
|
|
|
# Create a dedicated NGINX config
|
|
ynh_add_nginx_config
|
|
|
|
# Create a dedicated systemd config
|
|
ynh_add_systemd_config
|
|
yunohost service add "$app" --description="Mongo Express to easily administer your Mongo databases" --log="/var/log/$app/$app.log"
|
|
|
|
# Use logrotate to manage application logfile(s)
|
|
ynh_use_logrotate
|
|
|
|
#=================================================
|
|
# 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="/var/log/$app/$app.log"
|
|
|
|
#=================================================
|
|
# END OF SCRIPT
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Installation of $app completed" --last
|