1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/torrelay_ynh.git synced 2024-09-03 20:26:36 +02:00
This commit is contained in:
YunoHost Bot 2024-08-31 13:31:52 +02:00 committed by GitHub
commit e871115f53
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
13 changed files with 42 additions and 253 deletions

View file

@ -1,23 +0,0 @@
;; Test complet
; Manifest
domain="domain.tld"
contact="address@email.com"
nickname="john"
; Checks
pkg_linter=1
setup_sub_dir=0
setup_root=0
setup_nourl=1
setup_private=0
setup_public=0
upgrade=1
backup_restore=1
multi_instance=0
change_url=0
;;; Options
Email=
Notification=none
;;; Upgrade options
; commit=CommitHash
name=Name and date of the commit.
manifest_arg=domain=DOMAIN&path=PATH&is_public=1&language=fr&admin=USER&password=pass&port=666&

View file

@ -1,20 +0,0 @@
version = "1.0"
[main]
name = "Tor configuration"
services = ["tor"]
[main.config]
name = "Configuration Options"
[main.config.nickname]
ask = "Enable cover animation"
type = "string"
help = "Add a welcome message to the login screen"
bind = "/etc/tor/torrc"
[main.config.contact]
ask = "Allow music download"
type = "string"
help = "Add a welcome message to the login screen"
bind = "/etc/tor/torrc"

View file

@ -16,7 +16,8 @@ admindoc = "https://community.torproject.org/relay/setup/bridge/debian-ubuntu/"
code = "https://github.com/torproject/tor"
[integration]
yunohost = ">= 11.2"
yunohost = ">= 11.2.18"
helpers_version = "2.1"
architectures = ["amd64", "arm64", "i386"]
multi_instance = false
ldap ="not_relevant"

View file

@ -1,17 +1,5 @@
#!/bin/bash
#=================================================
# COMMON VARIABLES
#=================================================
#=================================================
# PERSONAL HELPERS
#=================================================
#=================================================
# EXPERIMENTAL HELPERS
#=================================================
#=================================================
# FUTURE OFFICIAL HELPERS
# COMMON VARIABLES AND CUSTOM HELPERS
#=================================================

View file

@ -1,28 +1,19 @@
#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers
#=================================================
# DECLARE DATA AND CONF FILES TO BACKUP
#=================================================
ynh_print_info --message="Declaring files to be backed up..."
ynh_print_info "Declaring files to be backed up..."
#=================================================
# BACKUP VARIOUS FILES
#=================================================
ynh_backup --src_path="/etc/tor/torrc"
ynh_backup "/etc/tor/torrc"
#=================================================
# END OF SCRIPT
#=================================================
ynh_print_info --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)."
ynh_print_info "Backup script completed for $app. (YunoHost will then actually copy those files to the archive)."

View file

@ -1,41 +1,31 @@
#!/bin/bash
#=================================================
# GENERIC STARTING
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# STANDARD MODIFICATIONS
#=================================================
# STOP SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Stopping a systemd service..." --weight=1
ynh_script_progression "Stopping $app's systemd service..."
ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log"
ynh_systemctl --service=$app --action="stop"
#=================================================
# MODIFY URL IN NGINX CONF
#=================================================
ynh_script_progression --message="Updating NGINX web server configuration..." --weight=1
ynh_script_progression "Updating NGINX web server configuration..."
ynh_change_url_nginx_config
ynh_config_change_url_nginx
#=================================================
# GENERIC FINALISATION
#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Starting a systemd service..." --weight=1
ynh_script_progression "Starting $app's systemd service..."
ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log"
ynh_systemctl --service=$app --action="start"
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Change of URL completed for $app" --last
ynh_script_progression "Change of URL completed for $app"

View file

@ -1,102 +0,0 @@
#!/bin/bash
# In simple cases, you don't need a config script.
# With a simple config_panel.toml, you can write in the app settings, in the
# upstream config file or replace complete files (logo ...) and restart services.
# The config scripts allows you to go further, to handle specific cases
# (validation of several interdependent fields, specific getter/setter for a value,
# display dynamic informations or choices, pre-loading of config type .cube... ).
#=================================================
# GENERIC STARTING
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source /usr/share/yunohost/helpers
ynh_abort_if_errors
#=================================================
# RETRIEVE ARGUMENTS
#=================================================
final_path=$(ynh_app_setting_get $app final_path)
#=================================================
# SPECIFIC GETTERS FOR TOML SHORT KEY
#=================================================
get__amount() {
# Here we can imagine to have an API call to stripe to know the amount of donation during a month
local amount = 200
# It's possible to change some properties of the question by overriding it:
if [ $amount -gt 100 ]
then
cat << EOF
style: success
value: $amount
ask:
en: A lot of donation this month: **$amount €**
EOF
else
cat << EOF
style: danger
value: $amount
ask:
en: Not so much donation this month: $amount €
EOF
fi
}
get__prices() {
local prices = "$(grep "DONATION\['" "$final_path/settings.py" | sed -r "s@^DONATION\['([^']*)'\]\['([^']*)'\] = '([^']*)'@\1/\2/\3@g" | sed -z 's/\n/,/g;s/,$/\n/')"
if [ "$prices" == "," ];
then
# Return YNH_NULL if you prefer to not return a value at all.
echo YNH_NULL
else
echo $prices
fi
}
#=================================================
# SPECIFIC VALIDATORS FOR TOML SHORT KEYS
#=================================================
validate__publishable_key() {
# We can imagine here we test if the key is really a publisheable key
(is_secret_key $publishable_key) &&
echo 'This key seems to be a secret key'
}
#=================================================
# SPECIFIC SETTERS FOR TOML SHORT KEYS
#=================================================
set__prices() {
#---------------------------------------------
# IMPORTANT: setter are trigger only if a change is detected
#---------------------------------------------
for price in $(echo $prices | sed "s/,/ /"); do
frequency=$(echo $price | cut -d/ -f1)
currency=$(echo $price | cut -d/ -f2)
price_id=$(echo $price | cut -d/ -f3)
sed "d/DONATION\['$frequency'\]\['$currency'\]" "$final_path/settings.py"
echo "DONATION['$frequency']['$currency'] = '$price_id'" >> "$final_path/settings.py"
done
#---------------------------------------------
# IMPORTANT: to be able to upgrade properly, you have to saved the value in settings too
#---------------------------------------------
ynh_app_setting_set $app prices $prices
}
#=================================================
# GENERIC FINALIZATION
#=================================================
ynh_app_config_run $1

View file

@ -1,11 +1,5 @@
#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh
source /usr/share/yunohost/helpers
@ -13,15 +7,15 @@ source /usr/share/yunohost/helpers
# STORE SETTINGS FROM MANIFEST
#=================================================
ynh_app_setting_set --app=$app --key=contact --value=$contact
ynh_app_setting_set --app=$app --key=nickname --value=$nickname
ynh_app_setting_set --key=contact --value=$contact
ynh_app_setting_set --key=nickname --value=$nickname
#=================================================
# ADD A CONFIGURATION
#=================================================
ynh_script_progression --message="Adding a configuration file..." --weight=1
ynh_script_progression "Adding $app's configuration..."
ynh_add_config --template="../conf/torrc" --destination="/etc/tor/torrc"
ynh_config_add --template="torrc" --destination="/etc/tor/torrc"
chmod 660 /etc/tor/torrc
chown :debian-tor /etc/tor/torrc
@ -29,20 +23,20 @@ chown :debian-tor /etc/tor/torrc
#=================================================
# INTEGRATE SERVICE IN YUNOHOST
#=================================================
ynh_script_progression --message="Integrating service in YunoHost..." --weight=2
ynh_script_progression "Integrating service in YunoHost..."
yunohost service add tor --description="Tor Relay" --log="/var/log/$app/$app.log" --needs_exposed_ports="$port_or" --test_status="pgrep tor"
#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Starting a systemd service..." --weight=3
ynh_script_progression "Starting $app's systemd service..."
# Start a systemd service
ynh_systemd_action --service_name=tor --action="restart" --log_path="systemd"
ynh_systemctl --service=tor --action="restart" --log_path="systemd"
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Installation of $app completed" --last
ynh_script_progression "Installation of $app completed"

View file

@ -1,11 +1,5 @@
#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh
source /usr/share/yunohost/helpers
@ -16,32 +10,32 @@ source /usr/share/yunohost/helpers
#=================================================
# Remove the service from the list of services known by YunoHost (added from `yunohost service add`)
if ynh_exec_warn_less yunohost service status tor >/dev/null
if ynh_hide_warnings yunohost service status tor >/dev/null
then
ynh_script_progression --message="Removing Tor service integration..." --weight=1
ynh_script_progression "Removing Tor service integration..."
yunohost service remove tor
fi
#=================================================
# STOP AND REMOVE SERVICE
#=================================================
ynh_script_progression --message="Stopping and removing the systemd service..." --weight=1
ynh_script_progression "Stopping and removing the systemd service..."
# Remove the dedicated systemd config
ynh_remove_systemd_config --service=tor
ynh_config_remove_systemdtor
#=================================================
# SPECIFIC REMOVE
#=================================================
# REMOVE VARIOUS FILES
#=================================================
ynh_script_progression --message="Removing various files..." --weight=2
ynh_script_progression "Removing various files..."
# Remove a cron file
ynh_secure_remove --file="/etc/tor/torrc"
ynh_safe_rm "/etc/tor/torrc"
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Removal of $app completed" --last
ynh_script_progression "Removal of $app completed"

View file

@ -1,11 +1,5 @@
#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers
@ -13,26 +7,26 @@ source /usr/share/yunohost/helpers
#=================================================
# RESTORE VARIOUS FILES
#=================================================
ynh_script_progression --message="Restoring various files..." --weight=1
ynh_script_progression "Restoring various files..."
ynh_restore_file --origin_path="/etc/tor/torrc"
ynh_restore "/etc/tor/torrc"
#=================================================
# INTEGRATE SERVICE IN YUNOHOST
#=================================================
ynh_script_progression --message="Integrating service in YunoHost..." --weight=1
ynh_script_progression "Integrating service in YunoHost..."
yunohost service add tor --description="Tor Relay" --log="/var/log/$app/$app.log" --needs_exposed_ports="$port_or" --test_status="pgrep tor"
#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Starting a systemd service..." --weight=1
ynh_script_progression "Starting $app's systemd service..."
ynh_systemd_action --service_name=tor --action="restart" --log_path="systemd"
ynh_systemctl --service=tor --action="restart" --log_path="systemd"
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Restoration completed for $app" --last
ynh_script_progression "Restoration completed for $app"

View file

@ -1,35 +1,21 @@
#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# CHECK VERSION
#=================================================
upgrade_type=$(ynh_check_app_version_changed)
#=================================================
# STANDARD UPGRADE STEPS
#=================================================
# STOP SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Stopping a systemd service..." --weight=1
ynh_script_progression "Stopping $app's systemd service..."
ynh_systemd_action --service_name=tor --action="stop" --log_path="systemd"
ynh_systemctl --service=tor --action="stop" --log_path="systemd"
#=================================================
# UPDATE A CONFIG FILE
#=================================================
ynh_script_progression --message="Updating a configuration file..." --weight=2
ynh_script_progression "Updating configuration..."
ynh_add_config --template="../conf/torrc" --destination="/etc/tor/torrc"
ynh_config_add --template="torrc" --destination="/etc/tor/torrc"
chmod 660 /etc/tor/torrc
chown :debian-tor /etc/tor/torrc
@ -37,19 +23,19 @@ chown :debian-tor /etc/tor/torrc
#=================================================
# INTEGRATE SERVICE IN YUNOHOST
#=================================================
ynh_script_progression --message="Integrating service in YunoHost..." --weight=1
ynh_script_progression "Integrating service in YunoHost..."
yunohost service add tor --description="Tor Relay" --log="/var/log/$app/$app.log" --needs_exposed_ports="$port_or" --test_status="pgrep tor"
#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Starting a systemd service..." --weight=1
ynh_script_progression "Starting $app's systemd service..."
ynh_systemd_action --service_name=tor --action="restart" --log_path="systemd"
ynh_systemctl --service=tor --action="restart" --log_path="systemd"
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Upgrade of $app completed" --last
ynh_script_progression "Upgrade of $app completed"

View file

@ -1,2 +0,0 @@
*~
*.sw[op]

View file

@ -1,2 +0,0 @@
*~
*.sw[op]