1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/gotosocial_ynh.git synced 2024-09-03 19:16:06 +02:00
This commit is contained in:
Éric Gaspar 2023-08-15 17:19:52 +02:00
parent dbebe1badf
commit 9e31857051
6 changed files with 25 additions and 198 deletions

View file

@ -8,26 +8,6 @@
# PERSONAL HELPERS # PERSONAL HELPERS
#================================================= #=================================================
# custom function to detect armv6 and armv7
# ($YNH_ARCH returns armhf for both...)
detect_arch(){
local architecture
if [ -n "$(uname -m | grep arm64)" ] || [ -n "$(uname -m | grep aarch64)" ]; then
architecture="arm64"
elif [ -n "$(uname -m | grep 64)" ]; then
architecture="x86-64"
elif [ -n "$(uname -m | grep 86)" ]; then
architecture="i386"
elif [ -n "$(uname -m | grep armv6)" ]; then
architecture="armv6"
elif [ -n "$(uname -m | grep armv7)" ]; then
architecture="armv7"
else
architecture="unknown"
fi
echo $architecture
}
# custom function to change bash bool 0/1 to false/true # custom function to change bash bool 0/1 to false/true
convert_bool(){ convert_bool(){
(("$1")) && echo "true" || echo "false" (("$1")) && echo "true" || echo "false"

View file

@ -148,23 +148,9 @@ ynh_app_setting_set --app="$app" --key=advanced_rate_limit_requests --value="$ad
#================================================= #=================================================
ynh_script_progression --message="Setting up source files..." --weight=1 ynh_script_progression --message="Setting up source files..." --weight=1
### `ynh_setup_source` is used to install an app from a zip or tar.gz file,
### downloaded from an upstream source, like a git repository.
### `ynh_setup_source` use the file conf/app.src
# detect_arch comes from _common.sh / personnal helpers
architecture=$(detect_arch)
# Download, check integrity, uncompress and patch the source from app.src # Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source --dest_dir="$install_dir" --source_id="$architecture" ynh_setup_source --dest_dir="$install_dir"
# FIXME: this should be managed by the core in the future
# Here, as a packager, you may have to tweak the ownerhsip/permissions
# such that the appropriate users (e.g. maybe www-data) can access
# files in some cases.
# But FOR THE LOVE OF GOD, do not allow r/x for "others" on the entire folder _
# this will be treated as a security issue.
chmod 750 "$install_dir"
chmod -R o-rwx "$install_dir" chmod -R o-rwx "$install_dir"
chown -R "$app:www-data" "$install_dir" chown -R "$app:www-data" "$install_dir"
@ -176,25 +162,13 @@ ynh_script_progression --message="Configuring NGINX web server..." --weight=1
# Create a dedicated NGINX config for the main domain # Create a dedicated NGINX config for the main domain
ynh_add_nginx_config ynh_add_nginx_config
#================================================= # Create a dedicated systemd config
# CREATE DATA DIRECTORY ynh_add_systemd_config
#=================================================
ynh_script_progression --message="Creating a data directory..." --weight=1
#REMOVEME? data_dir=/home/yunohost.app/$app # Use logrotate to manage application logfile(s)
#REMOVEME? ynh_app_setting_set --app="$app" --key=data_dir --value="$data_dir" ynh_use_logrotate
mkdir -p "$data_dir" yunohost service add "$app" --description="Gotosocial server" --log="/var/log/$app/$app.log"
# FIXME: this should be managed by the core in the future
# Here, as a packager, you may have to tweak the ownerhsip/permissions
# such that the appropriate users (e.g. maybe www-data) can access
# files in some cases.
# But FOR THE LOVE OF GOD, do not allow r/x for "others" on the entire folder -
# this will be treated as a security issue.
chmod 750 "$data_dir"
chmod -R o-rwx "$data_dir"
chown -R "$app:www-data" "$data_dir"
#================================================= #=================================================
# ADD A CONFIGURATION # ADD A CONFIGURATION
@ -203,37 +177,9 @@ ynh_script_progression --message="Adding a configuration file..." --weight=1
ynh_add_config --template="config.yaml" --destination="$install_dir/config.yaml" ynh_add_config --template="config.yaml" --destination="$install_dir/config.yaml"
# FIXME: this should be handled by the core in the future
# You may need to use chmod 600 instead of 400,
# for example if the app is expected to be able to modify its own config
chmod 400 "$install_dir/config.yaml" chmod 400 "$install_dir/config.yaml"
chown "$app:$app" "$install_dir/config.yaml" chown "$app:$app" "$install_dir/config.yaml"
#=================================================
# SETUP SYSTEMD
#=================================================
ynh_script_progression --message="Configuring a systemd service..." --weight=1
# Create a dedicated systemd config
ynh_add_systemd_config
#=================================================
# GENERIC FINALIZATION
#=================================================
# SETUP LOGROTATE
#=================================================
ynh_script_progression --message="Configuring log rotation..." --weight=1
# Use logrotate to manage application logfile(s)
ynh_use_logrotate
#=================================================
# INTEGRATE SERVICE IN YUNOHOST
#=================================================
ynh_script_progression --message="Integrating service in YunoHost..." --weight=1
yunohost service add "$app" --description="Gotosocial server" --log="/var/log/$app/$app.log"
#================================================= #=================================================
# CREATE ADMIN USER # CREATE ADMIN USER
#================================================= #=================================================

View file

@ -22,47 +22,15 @@ then
yunohost service remove "$app" yunohost service remove "$app"
fi fi
#=================================================
# STOP AND REMOVE SERVICE
#=================================================
ynh_script_progression --message="Stopping and removing the systemd service..." --weight=1
# Remove the dedicated systemd config # Remove the dedicated systemd config
ynh_remove_systemd_config ynh_remove_systemd_config
#=================================================
# REMOVE NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Removing NGINX web server configuration..." --weight=1
# Remove the dedicated NGINX config of the main domain # Remove the dedicated NGINX config of the main domain
ynh_remove_nginx_config ynh_remove_nginx_config
#=================================================
# REMOVE LOGROTATE CONFIGURATION
#=================================================
ynh_script_progression --message="Removing logrotate configuration..." --weight=1
# Remove the app-specific logrotate config # Remove the app-specific logrotate config
ynh_remove_logrotate ynh_remove_logrotate
#=================================================
# CLOSE A PORT
#=================================================
if yunohost firewall list | grep -q "\- $port$"
then
ynh_script_progression --message="Closing port $port..." --weight=1
ynh_exec_warn_less yunohost firewall disallow TCP "$port"
fi
#=================================================
# SPECIFIC REMOVE
#=================================================
# REMOVE VARIOUS FILES
#=================================================
ynh_script_progression --message="Removing various files..." --weight=1
# Remove the log files # Remove the log files
ynh_secure_remove --file="/var/log/$app" ynh_secure_remove --file="/var/log/$app"

View file

@ -10,15 +10,6 @@
source ../settings/scripts/_common.sh source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
#=================================================
# STANDARD RESTORATION STEPS
#=================================================
# RESTORE THE NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Restoring the NGINX configuration..." --weight=1
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
#================================================= #=================================================
# RESTORE THE APP MAIN DIR # RESTORE THE APP MAIN DIR
#================================================= #=================================================
@ -26,13 +17,6 @@ ynh_script_progression --message="Restoring the app main directory..." --weight=
ynh_restore_file --origin_path="$install_dir" ynh_restore_file --origin_path="$install_dir"
# FIXME: this should be managed by the core in the future
# Here, as a packager, you may have to tweak the ownerhsip/permissions
# such that the appropriate users (e.g. maybe www-data) can access
# files in some cases.
# But FOR THE LOVE OF GOD, do not allow r/x for "others" on the entire folder -
# this will be treated as a security issue.
chmod 750 "$install_dir"
chmod -R o-rwx "$install_dir" chmod -R o-rwx "$install_dir"
chown -R "$app:www-data" "$install_dir" chown -R "$app:www-data" "$install_dir"
@ -43,25 +27,13 @@ ynh_script_progression --message="Restoring the data directory..." --weight=5
ynh_restore_file --origin_path="$data_dir" --not_mandatory ynh_restore_file --origin_path="$data_dir" --not_mandatory
mkdir -p "$data_dir"
# FIXME: this should be managed by the core in the future
# Here, as a packager, you may have to tweak the ownerhsip/permissions
# such that the appropriate users (e.g. maybe www-data) can access
# files in some cases.
# But FOR THE LOVE OF GOD, do not allow r/x for "others" on the entire folder -
# this will be treated as a security issue.
chmod 750 "$data_dir"
chmod -R o-rwx "$data_dir"
chown -R "$app:www-data" "$data_dir" chown -R "$app:www-data" "$data_dir"
#================================================= #=================================================
# RESTORE THE POSTGRESQL DATABASE # RESTORE THE POSTGRESQL DATABASE
#================================================= #=================================================
#REMOVEME? #REMOVEME? ynh_script_progression --message="Restoring the PostgreSQL database..." --weight=5 ynh_script_progression --message="Restoring the PostgreSQL database..." --weight=5
#REMOVEME? #REMOVEME? ynh_psql_test_if_first_run
#REMOVEME? #REMOVEME? ynh_psql_setup_db --db_user="$db_user" --db_name="$db_name" --db_pwd="$db_pwd"
ynh_psql_execute_as_root --sql="CREATE EXTENSION IF NOT EXISTS unaccent;" --database="$db_name" ynh_psql_execute_as_root --sql="CREATE EXTENSION IF NOT EXISTS unaccent;" --database="$db_name"
ynh_psql_execute_as_root --sql="CREATE EXTENSION IF NOT EXISTS pg_trgm;" --database="$db_name" ynh_psql_execute_as_root --sql="CREATE EXTENSION IF NOT EXISTS pg_trgm;" --database="$db_name"
ynh_psql_execute_as_root --sql="CREATE EXTENSION IF NOT EXISTS citext;" --database="$db_name" ynh_psql_execute_as_root --sql="CREATE EXTENSION IF NOT EXISTS citext;" --database="$db_name"
@ -72,21 +44,13 @@ ynh_psql_execute_file_as_root --file="./db.sql" --database="$db_name"
# RESTORE VARIOUS FILES # RESTORE VARIOUS FILES
#================================================= #=================================================
mkdir -p "/var/log/$app" ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
#================================================= mkdir -p "/var/log/$app"
# RESTORE SYSTEMD
#=================================================
ynh_script_progression --message="Restoring the systemd configuration..." --weight=1
ynh_restore_file --origin_path="/etc/systemd/system/$app.service" ynh_restore_file --origin_path="/etc/systemd/system/$app.service"
systemctl enable "$app.service" --quiet systemctl enable "$app.service" --quiet
#=================================================
# INTEGRATE SERVICE IN YUNOHOST
#=================================================
ynh_script_progression --message="Integrating service in YunoHost..." --weight=1
yunohost service add "$app" --description="Gotosocial server" --log="/var/log/$app/$app.log" yunohost service add "$app" --description="Gotosocial server" --log="/var/log/$app/$app.log"
#================================================= #=================================================

View file

@ -13,12 +13,6 @@ source /usr/share/yunohost/helpers
# CHECK VERSION # CHECK VERSION
#================================================= #=================================================
### This helper will compare the version of the currently installed app and the version of the upstream package.
### $upgrade_type can have 2 different values
### - UPGRADE_APP if the upstream app version has changed
### - UPGRADE_PACKAGE if only the YunoHost package has changed
### ynh_check_app_version_changed will stop the upgrade if the app is up to date.
### UPGRADE_APP should be used to upgrade the core app only if there's an upgrade to do.
upgrade_type=$(ynh_check_app_version_changed) upgrade_type=$(ynh_check_app_version_changed)
#================================================= #=================================================
@ -228,16 +222,9 @@ then
architecture=$(detect_arch) architecture=$(detect_arch)
# Download, check integrity, uncompress and patch the source from app.src # Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source --dest_dir="$install_dir" --source_id="$architecture" --keep="config.yaml" ynh_setup_source --dest_dir="$install_dir" --keep="config.yaml"
fi fi
# FIXME: this should be managed by the core in the future
# Here, as a packager, you may have to tweak the ownerhsip/permissions
# such that the appropriate users (e.g. maybe www-data) can access
# files in some cases.
# But FOR THE LOVE OF GOD, do not allow r/x for "others" on the entire folder -
# this will be treated as a security issue.
chmod 750 "$install_dir"
chmod -R o-rwx "$install_dir" chmod -R o-rwx "$install_dir"
chown -R "$app:www-data" "$install_dir" chown -R "$app:www-data" "$install_dir"
@ -249,49 +236,24 @@ ynh_script_progression --message="Upgrading NGINX web server configuration..."
# Create a dedicated NGINX config for the main domain # Create a dedicated NGINX config for the main domain
ynh_add_nginx_config ynh_add_nginx_config
# Create a dedicated systemd config
ynh_add_systemd_config
# Use logrotate to manage app-specific logfile(s)
ynh_use_logrotate --non-append
yunohost service add "$app" --description="Gotosocial server" --log="/var/log/$app/$app.log"
#================================================= #=================================================
# UPDATE A CONFIG FILE # UPDATE A CONFIG FILE
#================================================= #=================================================
ynh_script_progression --message="Updating a configuration file..." ynh_script_progression --message="Updating a configuration file..."
### Same as during install
###
### The file will automatically be backed-up if it's found to be manually modified (because
### ynh_add_config keeps track of the file's checksum)
ynh_add_config --template="config.yaml" --destination="$install_dir/config.yaml" ynh_add_config --template="config.yaml" --destination="$install_dir/config.yaml"
# FIXME: this should be handled by the core in the future
# You may need to use chmod 600 instead of 400,
# for example if the app is expected to be able to modify its own config
chmod 400 "$install_dir/config.yaml" chmod 400 "$install_dir/config.yaml"
chown "$app:$app" "$install_dir/config.yaml" chown "$app:$app" "$install_dir/config.yaml"
#=================================================
# SETUP SYSTEMD
#=================================================
ynh_script_progression --message="Upgrading systemd configuration..."
# Create a dedicated systemd config
ynh_add_systemd_config
#=================================================
# GENERIC FINALIZATION
#=================================================
# SETUP LOGROTATE
#=================================================
ynh_script_progression --message="Upgrading logrotate configuration..."
# Use logrotate to manage app-specific logfile(s)
ynh_use_logrotate --non-append
#=================================================
# INTEGRATE SERVICE IN YUNOHOST
#=================================================
ynh_script_progression --message="Integrating service in YunoHost..."
yunohost service add "$app" --description="Gotosocial server" --log="/var/log/$app/$app.log"
#================================================= #=================================================
# START SYSTEMD SERVICE # START SYSTEMD SERVICE
#================================================= #=================================================

View file

@ -0,0 +1,7 @@
test_format = 1.0
[default]
# ------------
# Tests to run
# ------------