1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/planka_ynh.git synced 2024-09-03 20:06:00 +02:00
planka_ynh/scripts/install

91 lines
3.1 KiB
Text
Raw Normal View History

2023-12-13 21:25:13 +01:00
#!/bin/bash
source _common.sh
source /usr/share/yunohost/helpers
secret=$(ynh_string_random --length=50)
email=$(ynh_user_get_info --username=$admin --key=mail)
timezone="$(cat /etc/timezone)"
firstname=$(yunohost user list --fields firstname --output-as json | jq -r .users.$admin.firstname)
lastname=$(yunohost user list --fields lastname --output-as json | jq -r .users.$admin.lastname)
2023-12-14 12:22:31 +01:00
#=================================================
# STORE SETTINGS FROM MANIFEST
#=================================================
2024-06-23 21:23:05 +02:00
ynh_script_progression "Storing installation settings..."
2023-12-14 12:22:31 +01:00
2024-06-23 21:23:05 +02:00
ynh_app_setting_set --key=password --value="$password"
ynh_app_setting_set --key=firstname --value=$firstname
ynh_app_setting_set --key=lastname --value=$lastname
2023-12-14 12:22:31 +01:00
2023-12-13 21:25:13 +01:00
#=================================================
# INSTALL DEPENDENCIES
#=================================================
2024-06-23 21:23:05 +02:00
ynh_script_progression "Installing dependencies..."
2023-12-13 21:25:13 +01:00
2024-06-23 21:23:05 +02:00
ynh_nodejs_install
2023-12-13 21:25:13 +01:00
#=================================================
# APP "BUILD" (DEPLOYING SOURCES, VENV, COMPILING ETC)
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
2024-06-23 21:23:05 +02:00
ynh_script_progression "Setting up source files..."
2023-12-13 21:25:13 +01:00
ynh_setup_source --dest_dir="$install_dir"
2023-12-13 23:01:52 +01:00
chmod -R o-rwx "$install_dir"
2023-12-13 21:25:13 +01:00
chown -R $app:www-data "$install_dir"
#=================================================
# SYSTEM CONFIGURATION
#=================================================
2024-06-23 21:23:05 +02:00
ynh_script_progression "Adding system configurations related to $app..."
2023-12-13 21:25:13 +01:00
2024-06-23 21:23:05 +02:00
ynh_config_add_nginx
2023-12-13 21:25:13 +01:00
2024-06-23 21:23:05 +02:00
ynh_config_add_systemd
2023-12-13 21:25:13 +01:00
yunohost service add $app --description="Realtime kanban board for workgroups" --log="/var/log/$app/$app.log"
#=================================================
# APP INITIAL CONFIGURATION
#=================================================
# ADD A CONFIGURATION
#=================================================
2024-06-23 21:23:05 +02:00
ynh_script_progression "Adding $app's configuration..."
2023-12-13 21:25:13 +01:00
2024-06-23 21:23:05 +02:00
ynh_config_add --template=".env" --destination="$install_dir/.env"
2023-12-13 21:25:13 +01:00
chmod 400 "$install_dir/.env"
chown $app:$app "$install_dir/.env"
#=================================================
# INSTALL PLANKA
#=================================================
2024-06-23 21:23:05 +02:00
ynh_script_progression "Installing $app..."
2023-12-13 21:25:13 +01:00
pushd $install_dir
2024-06-23 21:23:05 +02:00
ynh_hide_warnings ynh_exec_as_app node_load_PATH npm install
ynh_hide_warnings ynh_exec_as_app node_load_PATH npm run db:init
2023-12-13 21:25:13 +01:00
popd
#=================================================
# START SYSTEMD SERVICE
#=================================================
2024-06-23 21:23:05 +02:00
ynh_script_progression "Starting $app's systemd service..."
2023-12-13 21:25:13 +01:00
2024-06-23 21:23:05 +02:00
ynh_systemctl --service=$app --action="start" --log_path="systemd"
2023-12-13 21:25:13 +01:00
2023-12-15 14:45:54 +01:00
#=================================================
# ADD FAIL2BAN
#=================================================
2024-06-23 21:23:05 +02:00
ynh_config_add_fail2ban --logpath="$install_dir/logs/planka.log" --failregex="^(.*) Invalid (email or username:|password!) (\"(.*)\"!)? ?\(IP: <ADDR>\)$"
2023-12-15 14:45:54 +01:00
2023-12-13 21:25:13 +01:00
#=================================================
# END OF SCRIPT
#=================================================
2024-06-23 21:23:05 +02:00
ynh_script_progression "Installation of $app completed"