mirror of
https://github.com/YunoHost-Apps/woodpecker_ynh.git
synced 2024-09-03 20:35:57 +02:00
106 lines
4.5 KiB
Bash
Executable file
106 lines
4.5 KiB
Bash
Executable file
#!/bin/bash
|
|
|
|
#=================================================
|
|
# GENERIC START
|
|
#=================================================
|
|
# IMPORT GENERIC HELPERS
|
|
#=================================================
|
|
|
|
source _common.sh
|
|
source /usr/share/yunohost/helpers
|
|
|
|
#=================================================
|
|
# APP "BUILD" (DEPLOYING SOURCES, VENV, COMPILING ETC)
|
|
#=================================================
|
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
|
#=================================================
|
|
ynh_script_progression --message="Setting up source files..." --weight=1
|
|
|
|
ynh_setup_source --dest_dir="$install_dir"
|
|
|
|
chown -R "$app:www-data" "$install_dir"
|
|
ls -lah "$install_dir"
|
|
|
|
#=================================================
|
|
# SYSTEM CONFIGURATION
|
|
#=================================================
|
|
ynh_script_progression --message="Adding system configurations related to $app..." --weight=1
|
|
|
|
ynh_add_nginx_config
|
|
|
|
ynh_add_systemd_config
|
|
|
|
yunohost service add "$app" --description="Woodpecker CI server" --log="/var/log/$app/$app.log"
|
|
|
|
### Additional options starting with 3.8:
|
|
###
|
|
### --needs_exposed_ports "$port" a list of ports that needs to be publicly exposed
|
|
### which will then be checked by YunoHost's diagnosis system
|
|
### (N.B. DO NOT USE THIS if the port is only internal!!!)
|
|
###
|
|
### --test_status "some command" a custom command to check the status of the service
|
|
### (only relevant if 'systemctl status' doesn't do a good job)
|
|
###
|
|
### --test_conf "some command" some command similar to "nginx -t" that validates the conf of the service
|
|
###
|
|
### Re-calling 'yunohost service add' during the upgrade script is the right way
|
|
### to proceed if you later realize that you need to enable some flags that
|
|
### weren't enabled on old installs (be careful it'll override the existing
|
|
### service though so you should re-provide all relevant flags when doing so)
|
|
|
|
### `ynh_use_logrotate` is used to configure a logrotate configuration for the logs of this app.
|
|
### Use this helper only if there is effectively a log file for this app.
|
|
### If you're not using this helper:
|
|
### - Remove the section "BACKUP LOGROTATE" in the backup script
|
|
### - Remove also the section "REMOVE LOGROTATE CONFIGURATION" in the remove script
|
|
### - As well as the section "RESTORE THE LOGROTATE CONFIGURATION" in the restore script
|
|
### - And the section "SETUP LOGROTATE" in the upgrade script
|
|
|
|
# Create log file before logrotate
|
|
mkdir -p "/var/log/$app"
|
|
touch "/var/log/$app/$app.log"
|
|
chown -R "$app:$app" "/var/log/$app"
|
|
chmod -R u=rwX,g=rX,o= "/var/log/$app"
|
|
|
|
# Use logrotate to manage application logfile(s)
|
|
ynh_use_logrotate
|
|
|
|
# Create a dedicated Fail2Ban config
|
|
# ynh_add_fail2ban_config --logpath="/var/log/nginx/${domain}-error.log" --failregex="Regex to match into the log for a failed login"
|
|
|
|
#=================================================
|
|
# APP INITIAL CONFIGURATION
|
|
#=================================================
|
|
# ADD A CONFIGURATION
|
|
#=================================================
|
|
ynh_script_progression --message="Adding a configuration file..." --weight=1
|
|
|
|
path_no_trailing_slash=${path%/}
|
|
_woodpecker_set_forge_config
|
|
|
|
ynh_add_config --template="woodpecker-server.conf" --destination="$install_dir/woodpecker-server.conf"
|
|
chmod 400 "$install_dir/woodpecker-server.conf"
|
|
chown "$app:$app" "$install_dir/woodpecker-server.conf"
|
|
|
|
#=================================================
|
|
# GENERIC FINALIZATION
|
|
#=================================================
|
|
# START SYSTEMD SERVICE
|
|
#=================================================
|
|
ynh_script_progression --message="Starting a systemd service..." --weight=1
|
|
|
|
### `ynh_systemd_action` is used to start a systemd service for an app.
|
|
### Only needed if you have configure a systemd service
|
|
### If you're not using these lines:
|
|
### - Remove the section "STOP SYSTEMD SERVICE" and "START SYSTEMD SERVICE" in the backup script
|
|
### - As well as the section "START SYSTEMD SERVICE" in the restore script
|
|
### - As well as the section"STOP SYSTEMD SERVICE" and "START SYSTEMD SERVICE" in the upgrade script
|
|
### - And the section "STOP SYSTEMD SERVICE" and "START SYSTEMD SERVICE" in the change_url script
|
|
|
|
# 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
|