1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/zeronet_ynh.git synced 2024-09-03 17:46:12 +02:00

Update manifestv2

This commit is contained in:
Salamandar 2024-01-19 17:41:44 +01:00
parent 09c4425911
commit 088d993a47
8 changed files with 58 additions and 149 deletions

View file

@ -6,8 +6,8 @@ After=network.target
Type=simple
User=__APP__
Group=__APP__
WorkingDirectory=__INSTALL_DIR__/
ExecStart=__INSTALL_DIR__/venv/bin/python3 __INSTALL_DIR__/zeronet.py --ui_port __PORT__ --ui_host __DOMAIN__ --fileserver_port __PORT_FS__ --data_dir __DATA_DIR__/data --log_dir __DATA_DIR__/log --ui_password __PASSWORD__
WorkingDirectory=__INSTALL_DIR__/source/
ExecStart=__INSTALL_DIR__/venv/bin/python3 __INSTALL_DIR__/source/zeronet.py --ui_port __PORT__ --ui_host __DOMAIN__ --fileserver_port __PORT_FS__ --data_dir __DATA_DIR__/data --log_dir __DATA_DIR__/log --ui_password __PASSWORD__
ExecReload=/bin/kill -HUP $MAINPID
KillMode=process
Restart=on-failure

View file

@ -1,11 +1,13 @@
## Install instructions
- This app can only be installed on root path, i.e you will need to use a dedicated domain name, e.g.`zeronet.domain.tld`.
- You can setup Tor which has to be done manually till its implimented in the app.[how to use zeronet with Tor](https://zeronet.readthedocs.io/en/latest/faq/#how-to-use-zeronet-with-tor)
## Multiple Instances
- Installing multiple instances of the app is *experimental*. Internally each instance will use an unique port for both for ZeroNet UserInterface and FileServer. However, the tracker will see all instances as one peer, as they all use one and the same external IP address. But you try it and explain your user case.
- A solution that hasn't been confirmed yet is to use Tor instead. Each instance should then have a unique external address.
## Limitations
* App can not be used inside SSO. See [here](https://github.com/HelloZeroNet/ZeroNet/issues/2541) and [here](https://github.com/YunoHost/issues/issues/1580).
- App can not be used inside SSO. See [here](https://github.com/HelloZeroNet/ZeroNet/issues/2541) and [here](https://github.com/YunoHost/issues/issues/1580).

View file

@ -22,7 +22,6 @@ fund = "???" # FIXME: optional but recommended (or remove if irrelevant / not ap
yunohost = ">= 4.3.0"
architectures = "all" # FIXME: can be replaced by a list of supported archs using the dpkg --print-architecture nomenclature (amd64/i386/armhf/arm64), for example: ["amd64", "i386"]
multi_instance = true
ldap = "?" # FIXME: replace with true, false, or "not_relevant". Not to confuse with the "sso" key : the "ldap" key corresponds to wether or not a user *can* login on the app using its YunoHost credentials.
sso = "?" # FIXME: replace with true, false, or "not_relevant". Not to confuse with the "ldap" key : the "sso" key corresponds to wether or not a user is *automatically logged-in* on the app when logged-in on the YunoHost portal.
disk = "50M" # FIXME: replace with an **estimate** minimum disk requirement. e.g. 20M, 400M, 1G, ...
@ -56,6 +55,7 @@ ram.runtime = "50M" # FIXME: replace with an **estimate** minimum ram requiremen
[resources.ports]
main.default = 43110
fs.default = 15441
fs.exposed = "TCP"
[resources.apt]
packages = [

View file

@ -33,12 +33,13 @@ ynh_change_url_nginx_config
ynh_script_progression --message="Integrating service in YunoHost..."
ynh_replace_string --match_string="$old_domain" --replace_string="$new_domain" --target_file="/etc/systemd/system/${app}.service"
systemctl daemon-reload
#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="Ui.UiServer Web interface" --timeout=120
ynh_systemd_action --service_name="$app" --action="start" --log_path="systemd" --line_match="Ui.UiServer Web interface" --timeout=120
#=================================================
# END OF SCRIPT

View file

@ -11,29 +11,21 @@ source /usr/share/yunohost/helpers
path="/"
# Open the port
ynh_script_progression --message="Configuring firewall..."
ynh_exec_warn_less yunohost firewall allow --no-upnp TCP $fs_port
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
ynh_script_progression --message="Setting up source files..."
# Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source --dest_dir="$install_dir"
ynh_setup_source --dest_dir="$install_dir/source"
chmod 750 "$install_dir"
chmod -R o-rwx "$install_dir"
chown -R $app:$app "$install_dir"
chown -R "$app:$app" "$install_dir"
#=================================================
# NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Configuring NGINX web server..."
# Create a dedicated NGINX config
ynh_add_nginx_config
chmod 750 "$data_dir"
chmod -R o-rwx "$data_dir"
chown -R "$app:$app" "$data_dir"
#=================================================
# SPECIFIC SETUP
@ -42,38 +34,24 @@ ynh_add_nginx_config
#=================================================
ynh_script_progression --message="Building zeronet..."
pushd "$install_dir"
ynh_exec_as "$app" python3 -m venv venv
ynh_exec_as "$app" venv/bin/pip install --upgrade pip
ynh_exec_as "$app" venv/bin/pip install -r requirements.txt
popd
ynh_exec_as "$app" python3 -m venv --upgrade "$install_dir/venv"
ynh_exec_as "$app" "$install_dir/venv/bin/python3" -m pip install --upgrade pip
ynh_exec_as "$app" "$install_dir/venv/bin/python3" -m pip install -r "$install_dir/source/requirements.txt"
# Enable password authentication for Zeronet
mv "$install_dir/plugins/disabled-UiPassword" "$install_dir/plugins/UiPassword"
mv "$install_dir/source/plugins/disabled-UiPassword" "$install_dir/source/plugins/UiPassword"
#=================================================
# CREATE DATA DIRECTORY
# SYSTEM CONFIGURATION
#=================================================
ynh_script_progression --message="Creating a data directory..."
ynh_script_progression --message="Adding system configurations related to $app..." --weight=1
chmod 750 "$data_dir"
chmod -R o-rwx "$data_dir"
chown -R $app:$app "$data_dir"
#=================================================
# SETUP SYSTEMD
#=================================================
ynh_script_progression --message="Configuring a systemd service..."
# Create a dedicated NGINX config
ynh_add_nginx_config
# Create a dedicated systemd config
ynh_add_systemd_config
#=================================================
# INTEGRATE SERVICE IN YUNOHOST
#=================================================
ynh_script_progression --message="Integrating service in YunoHost..."
yunohost service add $app --description="$app service" --log="$data_dir/log/debug-last.log" --needs_exposed_ports="$port_fs"
yunohost service add "$app" --description="$app service" --log="$data_dir/log/debug-last.log" --needs_exposed_ports="$port_fs"
#=================================================
# START SYSTEMD SERVICE
@ -81,7 +59,7 @@ yunohost service add $app --description="$app service" --log="$data_dir/log/debu
ynh_script_progression --message="Starting a systemd service..."
# Start a systemd service
ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="Ui.UiServer Web interface" --timeout=120
ynh_systemd_action --service_name="$app" --action="start" --log_path="systemd" --line_match="Ui.UiServer Web interface" --timeout=120
#=================================================
# END OF SCRIPT

View file

@ -10,44 +10,21 @@ source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# STANDARD REMOVE
#=================================================
# REMOVE SERVICE INTEGRATION IN YUNOHOST
# REMOVE SYSTEM CONFIGURATIONS
#=================================================
ynh_script_progression --message="Removing system configurations related to $app..." --weight=1
# Remove the service from the list of services known by YunoHost (added from `yunohost service add`)
if ynh_exec_warn_less yunohost service status $app >/dev/null
then
ynh_script_progression --message="Removing $app service integration..."
if ynh_exec_warn_less yunohost service status "$app" >/dev/null; then
yunohost service remove $app
fi
#=================================================
# STOP AND REMOVE SERVICE
#=================================================
ynh_script_progression --message="Stopping and removing the systemd service..."
# Remove the dedicated systemd config
ynh_remove_systemd_config
#=================================================
# REMOVE NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Removing NGINX web server configuration..."
# Remove the dedicated NGINX config
ynh_remove_nginx_config
#=================================================
# CLOSE A PORT
#=================================================
if yunohost firewall list | grep -q "\- $port_fs$"
then
ynh_script_progression --message="Closing port $port..."
ynh_exec_warn_less yunohost firewall disallow TCP $port_fs
fi
#=================================================
# END OF SCRIPT
#=================================================

View file

@ -19,7 +19,7 @@ ynh_restore_file --origin_path="$install_dir"
chmod 750 "$install_dir"
chmod -R o-rwx "$install_dir"
chown -R $app:$app "$install_dir"
chown -R "$app:$app" "$install_dir"
#=================================================
# RESTORE THE DATA DIRECTORY
@ -30,54 +30,32 @@ ynh_restore_file --origin_path="$data_dir" --not_mandatory
chmod 750 "$data_dir"
chmod -R o-rwx "$data_dir"
chown -R $app:$app "$data_dir"
#=================================================
# RESTORE THE NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Restoring the NGINX web server configuration..."
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
chown -R "$app:$app" "$data_dir"
#=================================================
# BUILDING ZERONET
#=================================================
ynh_script_progression --message="Building zeronet..."
ynh_script_progression --message="Updating virtualenv..."
pushd "$install_dir"
python3 -m venv venv
venv/bin/pip install --upgrade pip
venv/bin/pip install -r requirements.txt
popd
ynh_exec_as "$app" python3 -m venv --upgrade "$install_dir/venv"
#=================================================
# RESTORE SYSTEMD
# RESTORE SYSTEM CONFIGURATIONS
#=================================================
ynh_script_progression --message="Restoring the systemd configuration..."
ynh_script_progression --message="Restoring system configurations related to $app..." --weight=1
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
ynh_restore_file --origin_path="/etc/systemd/system/$app.service"
systemctl enable $app.service --quiet
systemctl enable "$app.service" --quiet
yunohost service add "$app" --description="$app service" --log="$data_dir/log/debug-last.log" --needs_exposed_ports="$port_fs"
#=================================================
# INTEGRATE SERVICE IN YUNOHOST
# RELOAD NGINX AND PHP-FPM OR THE APP SERVICE
#=================================================
ynh_script_progression --message="Integrating service in YunoHost..."
ynh_script_progression --message="Reloading NGINX web server and $app's service..." --weight=1
yunohost service add $app --description="$app service" --log="$data_dir/log/debug-last.log" --needs_exposed_ports="$port_fs"
#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Starting a systemd service..."
ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="Ui.UiServer Web interface" --timeout=120
#=================================================
# GENERIC FINALIZATION
#=================================================
# RELOAD NGINX
#=================================================
ynh_script_progression --message="Reloading NGINX web server..."
ynh_systemd_action --service_name="$app" --action="start" --log_path="/var/log/$app/$app.log"
ynh_systemd_action --service_name=nginx --action=reload

View file

@ -9,8 +9,6 @@
source _common.sh
source /usr/share/yunohost/helpers
upgrade_type=$(ynh_check_app_version_changed)
#=================================================
# STANDARD UPGRADE STEPS
#=================================================
@ -23,32 +21,23 @@ ynh_systemd_action --service_name=$app --action="stop" --log_path="systemd"
#=================================================
# ENSURE DOWNWARD COMPATIBILITY
#=================================================
ynh_script_progression --message="Ensuring downward compatibility..."
# ynh_script_progression --message="Ensuring downward compatibility..."
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
if [ "$upgrade_type" == "UPGRADE_APP" ]
then
ynh_script_progression --message="Upgrading source files..."
# Download, check integrity, uncompress and patch the source from app.src
ynh_secure_remove --file="$install_dir"
ynh_setup_source --dest_dir="$install_dir"
fi
ynh_setup_source --dest_dir="$install_dir/source" --full_replace=1
chmod 750 "$install_dir"
chmod -R o-rwx "$install_dir"
chown -R $app:$app "$install_dir"
chown -R "$app:$app" "$install_dir"
#=================================================
# NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Upgrading NGINX web server configuration..."
# Create a dedicated NGINX config
ynh_add_nginx_config
chmod 750 "$data_dir"
chmod -R o-rwx "$data_dir"
chown -R "$app:$app" "$data_dir"
#=================================================
# SPECIFIC UPGRADE
@ -57,47 +46,31 @@ ynh_add_nginx_config
#=================================================
ynh_script_progression --message="Building zeronet..."
pushd "$install_dir"
ynh_exec_as "$app" python3 -m venv venv
ynh_exec_as "$app" venv/bin/pip install --upgrade pip
ynh_exec_as "$app" venv/bin/pip install -r requirements.txt
popd
ynh_exec_as "$app" python3 -m venv --upgrade "$install_dir/venv"
ynh_exec_as "$app" "$install_dir/venv/bin/python3" -m pip install --upgrade pip
ynh_exec_as "$app" "$install_dir/venv/bin/python3" -m pip install -r "$install_dir/source/requirements.txt"
# Enable password authentication for Zeronet
mv "$install_dir/plugins/disabled-UiPassword" "$install_dir/plugins/UiPassword"
mv "$install_dir/source/plugins/disabled-UiPassword" "$install_dir/source/plugins/UiPassword"
#=================================================
# CREATE DATA DIR
# REAPPLY SYSTEM CONFIGURATIONS
#=================================================
ynh_script_progression --message="Creating data directory..."
ynh_script_progression --message="Upgrading system configurations related to $app..." --weight=1
chmod 750 "$data_dir"
chmod -R o-rwx "$data_dir"
chown -R $app:$app "$data_dir"
#=================================================
# SETUP SYSTEMD
#=================================================
ynh_script_progression --message="Upgrading systemd configuration..."
# Create a dedicated NGINX config
ynh_add_nginx_config
# Create a dedicated systemd config
ynh_add_systemd_config
#=================================================
# GENERIC FINALIZATION
#=================================================
# INTEGRATE SERVICE IN YUNOHOST
#=================================================
ynh_script_progression --message="Integrating service in YunoHost..."
yunohost service add $app --description="$app service" --log="$data_dir/log/debug-last.log" --needs_exposed_ports="$port_fs"
yunohost service add "$app" --description="$app service" --log="$data_dir/log/debug-last.log" --needs_exposed_ports="$port_fs"
#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Starting a systemd service..."
ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="Ui.UiServer Web interface" --timeout=120
ynh_systemd_action --service_name="$app" --action="start" --log_path="systemd" --line_match="Ui.UiServer Web interface" --timeout=120
#=================================================
# END OF SCRIPT