mirror of
https://github.com/YunoHost-Apps/octoprint_ynh.git
synced 2024-09-03 19:46:26 +02:00
Automated packaging v2 conversion
This commit is contained in:
parent
4a7145bab8
commit
3747d497dc
7 changed files with 109 additions and 59 deletions
50
manifest.toml
Normal file
50
manifest.toml
Normal file
|
@ -0,0 +1,50 @@
|
||||||
|
#:schema https://raw.githubusercontent.com/YunoHost/apps/master/schemas/manifest.v2.schema.json
|
||||||
|
|
||||||
|
packaging_format = 2
|
||||||
|
|
||||||
|
id = "octoprint"
|
||||||
|
name = "Octoprint"
|
||||||
|
description.en = "3D printing webserver"
|
||||||
|
description.fr = "Serveur d'impression 3D"
|
||||||
|
|
||||||
|
version = "1.0.0"
|
||||||
|
|
||||||
|
maintainers = ["Tropicao"]
|
||||||
|
|
||||||
|
[upstream]
|
||||||
|
license = "Apache-2.0"
|
||||||
|
website = "https://github.com/Tropicao/octoprint_ynh"
|
||||||
|
cpe = "???" # FIXME: optional but recommended if relevant, this is meant to contain the Common Platform Enumeration, which is sort of a standard id for applications defined by the NIST. In particular, Yunohost may use this is in the future to easily track CVE (=security reports) related to apps. The CPE may be obtained by searching here: https://nvd.nist.gov/products/cpe/search. For example, for Nextcloud, the CPE is 'cpe:2.3:a:nextcloud:nextcloud' (no need to include the version number)
|
||||||
|
fund = "???" # FIXME: optional but recommended (or remove if irrelevant / not applicable). This is meant to be an URL where people can financially support this app, especially when its development is based on volunteers and/or financed by its community. YunoHost may later advertise it in the webadmin.
|
||||||
|
|
||||||
|
[integration]
|
||||||
|
yunohost = ">= 3.1"
|
||||||
|
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 = false
|
||||||
|
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, ...
|
||||||
|
ram.build = "50M" # FIXME: replace with an **estimate** minimum ram requirement. e.g. 50M, 400M, 1G, ...
|
||||||
|
ram.runtime = "50M" # FIXME: replace with an **estimate** minimum ram requirement. e.g. 50M, 400M, 1G, ...
|
||||||
|
|
||||||
|
[install]
|
||||||
|
[install.domain]
|
||||||
|
# this is a generic question - ask strings are automatically handled by Yunohost's core
|
||||||
|
type = "domain"
|
||||||
|
|
||||||
|
[install.init_main_permission]
|
||||||
|
help.en = "If public, your 3D printer will be accessible by anyone on internet"
|
||||||
|
help.fr = "Dans ce cas, n'importe qui sur internet pourra utiliser votre imprimante"
|
||||||
|
type = "group"
|
||||||
|
default = false
|
||||||
|
|
||||||
|
[resources]
|
||||||
|
[resources.system_user]
|
||||||
|
|
||||||
|
[resources.install_dir]
|
||||||
|
|
||||||
|
[resources.permissions]
|
||||||
|
main.url = "/"
|
||||||
|
|
||||||
|
[resources.ports]
|
||||||
|
main.default = 5000
|
|
@ -316,7 +316,7 @@ ynh_check_starting () {
|
||||||
}
|
}
|
||||||
|
|
||||||
# Clean temporary process and file used by ynh_check_starting
|
# Clean temporary process and file used by ynh_check_starting
|
||||||
# (usually used in ynh_clean_setup scripts)
|
#REMOVEME? # (usually used in ynh_clean_setup scripts)
|
||||||
#
|
#
|
||||||
# usage: ynh_clean_check_starting
|
# usage: ynh_clean_check_starting
|
||||||
ynh_clean_check_starting () {
|
ynh_clean_check_starting () {
|
||||||
|
|
|
@ -6,18 +6,18 @@
|
||||||
source /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
# manage script failure
|
# manage script failure
|
||||||
ynh_abort_if_errors
|
#REMOVEME? ynh_abort_if_errors
|
||||||
|
|
||||||
# retrieve arguments
|
# retrieve arguments
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
#REMOVEME? app=$YNH_APP_INSTANCE_NAME
|
||||||
domain=$(ynh_app_setting_get "$app" domain)
|
#REMOVEME? domain=$(ynh_app_setting_get "$app" domain)
|
||||||
|
|
||||||
# definie useful vars
|
# definie useful vars
|
||||||
final_path="/opt/yunohost/$app"
|
#REMOVEME? install_dir="/opt/yunohost/$app"
|
||||||
home_path="/home/$app"
|
home_path="/home/$app"
|
||||||
|
|
||||||
# backup source & conf files
|
# backup source & conf files
|
||||||
ynh_backup "$final_path"
|
ynh_backup "$install_dir"
|
||||||
ynh_backup "$home_path"
|
ynh_backup "$home_path"
|
||||||
ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf"
|
ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||||
ynh_backup "/etc/sudoers.d/$app"
|
ynh_backup "/etc/sudoers.d/$app"
|
||||||
|
|
|
@ -4,50 +4,50 @@ source _common.sh
|
||||||
source /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
# manage script failure
|
# manage script failure
|
||||||
ynh_abort_if_errors
|
#REMOVEME? ynh_abort_if_errors
|
||||||
|
|
||||||
# retrieve arguments
|
# retrieve arguments
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
#REMOVEME? app=$YNH_APP_INSTANCE_NAME
|
||||||
domain=$YNH_APP_ARG_DOMAIN
|
#REMOVEME? domain=$YNH_APP_ARG_DOMAIN
|
||||||
is_public=$YNH_APP_ARG_IS_PUBLIC
|
#REMOVEME? is_public=$YNH_APP_ARG_IS_PUBLIC
|
||||||
|
|
||||||
# definie useful vars
|
# definie useful vars
|
||||||
final_path="/opt/yunohost/$app"
|
#REMOVEME? install_dir="/opt/yunohost/$app"
|
||||||
home_path="/home/$app"
|
home_path="/home/$app"
|
||||||
data_path="/home/$app/.$app"
|
data_path="/home/$app/.$app"
|
||||||
|
|
||||||
# check domain/path availability
|
# check domain/path availability
|
||||||
ynh_script_progression --message="Validating installation parameters..."
|
#REMOVEME? ynh_script_progression --message="Validating installation parameters..."
|
||||||
path_url=$(ynh_normalize_url_path "/")
|
path=$(ynh_normalize_url_path "/")
|
||||||
ynh_webpath_available "$domain" "$path_url" || ynh_die "$domain/$path_url is not available, please use an other domain."
|
#REMOVEME? ynh_webpath_available "$domain" "$path" || ynh_die "$domain/$path is not available, please use an other domain."
|
||||||
ynh_webpath_register $app "$domain" "$path_url"
|
#REMOVEME? ynh_webpath_register $app "$domain" "$path"
|
||||||
|
|
||||||
# add required packages
|
# add required packages
|
||||||
ynh_script_progression --message="Installing dependencies..."
|
#REMOVEME? ynh_script_progression --message="Installing dependencies..."
|
||||||
ynh_install_app_dependencies "$PKG_DEPENDENCIES"
|
#REMOVEME? ynh_install_app_dependencies "$PKG_DEPENDENCIES"
|
||||||
|
|
||||||
# save app settings
|
# save app settings
|
||||||
ynh_script_progression --message="Storing installation settings..."
|
#REMOVEME? ynh_script_progression --message="Storing installation settings..."
|
||||||
ynh_app_setting_set $app domain "$domain"
|
#REMOVEME? ynh_app_setting_set $app domain "$domain"
|
||||||
ynh_app_setting_set $app is_public $is_public
|
#REMOVEME? ynh_app_setting_set $app is_public $is_public
|
||||||
|
|
||||||
# find a free port & open it
|
# find a free port & open it
|
||||||
ynh_script_progression --message="Looking for a free port and opening it..."
|
ynh_script_progression --message="Looking for a free port and opening it..."
|
||||||
port=$(ynh_find_port 5000)
|
#REMOVEME? port=$(ynh_find_port 5000)
|
||||||
ynh_app_setting_set $app port $port
|
#REMOVEME? ynh_app_setting_set $app port $port
|
||||||
ynh_exec_fully_quiet yunohost firewall allow TCP $port
|
ynh_exec_fully_quiet yunohost firewall allow TCP $port
|
||||||
|
|
||||||
# create a dedicated system user
|
# create a dedicated system user
|
||||||
ynh_script_progression --message="Creating dedicated user, rights and folders..."
|
ynh_script_progression --message="Creating dedicated user, rights and folders..."
|
||||||
ynh_system_user_create $app
|
#REMOVEME? ynh_system_user_create $app
|
||||||
# add user to group dialout to allow ttyUSB usage
|
# add user to group dialout to allow ttyUSB usage
|
||||||
usermod -a -G dialout $app
|
usermod -a -G dialout $app
|
||||||
## grant sudo permissions to the user to manage his own systemd service
|
## grant sudo permissions to the user to manage his own systemd service
|
||||||
myynh_create_dir "/etc/sudoers.d"
|
myynh_create_dir "/etc/sudoers.d"
|
||||||
cp "../conf/sudoers" "/etc/sudoers.d/$app"
|
cp "../conf/sudoers" "/etc/sudoers.d/$app"
|
||||||
## create a directory for the installation of Octoprint
|
## create a directory for the installation of Octoprint
|
||||||
myynh_create_dir "$final_path"
|
myynh_create_dir "$install_dir"
|
||||||
chown $app: "$final_path"
|
chown $app: "$install_dir"
|
||||||
## create a directory for the datas of Octoprint
|
## create a directory for the datas of Octoprint
|
||||||
myynh_create_dir "$data_path"
|
myynh_create_dir "$data_path"
|
||||||
chown -R $app: "$home_path"
|
chown -R $app: "$home_path"
|
||||||
|
@ -56,9 +56,9 @@ chown -R $app: "$home_path"
|
||||||
ynh_script_progression --message="Installing Octoprint in a virtual environment..."
|
ynh_script_progression --message="Installing Octoprint in a virtual environment..."
|
||||||
exec_as $app -H -s /bin/bash -c " \
|
exec_as $app -H -s /bin/bash -c " \
|
||||||
echo 'create the virtual environment' \
|
echo 'create the virtual environment' \
|
||||||
&& virtualenv -p $(which python3) "$final_path" \
|
&& virtualenv -p $(which python3) "$install_dir" \
|
||||||
&& echo 'install Octoprint' \
|
&& echo 'install Octoprint' \
|
||||||
&& "$final_path"/bin/pip3 install $app \
|
&& "$install_dir"/bin/pip3 install $app \
|
||||||
"
|
"
|
||||||
|
|
||||||
# set default configuration files
|
# set default configuration files
|
||||||
|
|
|
@ -6,19 +6,19 @@ source _common.sh
|
||||||
source /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
# retrieve arguments
|
# retrieve arguments
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
#REMOVEME? app=$YNH_APP_INSTANCE_NAME
|
||||||
domain=$(ynh_app_setting_get "$app" domain)
|
#REMOVEME? domain=$(ynh_app_setting_get "$app" domain)
|
||||||
port=$(ynh_app_setting_get $app port)
|
#REMOVEME? port=$(ynh_app_setting_get $app port)
|
||||||
|
|
||||||
# definie useful vars
|
# definie useful vars
|
||||||
final_path="/opt/yunohost/$app"
|
#REMOVEME? install_dir="/opt/yunohost/$app"
|
||||||
home_path="/home/$app"
|
home_path="/home/$app"
|
||||||
|
|
||||||
# remove metapackage and its dependencies
|
# remove metapackage and its dependencies
|
||||||
ynh_remove_app_dependencies
|
#REMOVEME? ynh_remove_app_dependencies
|
||||||
|
|
||||||
# remove the app directory securely
|
# remove the app directory securely
|
||||||
ynh_secure_remove "$final_path"
|
#REMOVEME? ynh_secure_remove "$install_dir"
|
||||||
|
|
||||||
# remove the dedicated nginx config
|
# remove the dedicated nginx config
|
||||||
ynh_remove_nginx_config
|
ynh_remove_nginx_config
|
||||||
|
@ -41,7 +41,7 @@ ynh_secure_remove "/etc/systemd/system/$app@$app.service"
|
||||||
ynh_exec_fully_quiet yunohost firewall disallow TCP $port
|
ynh_exec_fully_quiet yunohost firewall disallow TCP $port
|
||||||
|
|
||||||
# delete a system user
|
# delete a system user
|
||||||
ynh_system_user_delete "$app"
|
#REMOVEME? ynh_system_user_delete "$app"
|
||||||
|
|
||||||
# remove sudoers file
|
# remove sudoers file
|
||||||
ynh_secure_remove "/etc/sudoers.d/$app"
|
ynh_secure_remove "/etc/sudoers.d/$app"
|
||||||
|
|
|
@ -8,28 +8,28 @@ source ../settings/scripts/_common.sh
|
||||||
source /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
# manage script failure
|
# manage script failure
|
||||||
ynh_abort_if_errors
|
#REMOVEME? ynh_abort_if_errors
|
||||||
|
|
||||||
# retrieve arguments
|
# retrieve arguments
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
#REMOVEME? app=$YNH_APP_INSTANCE_NAME
|
||||||
domain=$(ynh_app_setting_get "$app" domain)
|
#REMOVEME? domain=$(ynh_app_setting_get "$app" domain)
|
||||||
port=$(ynh_app_setting_get "$app" port)
|
#REMOVEME? port=$(ynh_app_setting_get "$app" port)
|
||||||
|
|
||||||
# definie useful vars
|
# definie useful vars
|
||||||
final_path="/opt/yunohost/$app"
|
#REMOVEME? install_dir="/opt/yunohost/$app"
|
||||||
home_path="/home/$app"
|
home_path="/home/$app"
|
||||||
data_path="/home/$app/.$app"
|
data_path="/home/$app/.$app"
|
||||||
|
|
||||||
# check domain/path availability
|
# check domain/path availability
|
||||||
path_url=$(ynh_normalize_url_path "/")
|
path=$(ynh_normalize_url_path "/")
|
||||||
ynh_webpath_available $domain $path_url || ynh_die "$domain/$path_url is not available, please use an other domain."
|
#REMOVEME? ynh_webpath_available $domain $path || ynh_die "$domain/$path is not available, please use an other domain."
|
||||||
|
|
||||||
# add required packages
|
# add required packages
|
||||||
ynh_install_app_dependencies "$PKG_DEPENDENCIES"
|
#REMOVEME? ynh_install_app_dependencies "$PKG_DEPENDENCIES"
|
||||||
|
|
||||||
# restore dedicated system user
|
# restore dedicated system user
|
||||||
ynh_system_user_exists "$app" && ynh_die "User $app is not available"
|
ynh_system_user_exists "$app" && ynh_die "User $app is not available"
|
||||||
ynh_system_user_create "$app"
|
#REMOVEME? ynh_system_user_create "$app"
|
||||||
|
|
||||||
# restore conf files
|
# restore conf files
|
||||||
ynh_restore_file "/etc/nginx/conf.d/$domain.d/$app.conf"
|
ynh_restore_file "/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||||
|
@ -37,10 +37,10 @@ ynh_restore_file "/etc/sudoers.d/$app"
|
||||||
ynh_restore_file "/etc/systemd/system/$app@$app.service"
|
ynh_restore_file "/etc/systemd/system/$app@$app.service"
|
||||||
|
|
||||||
# restore source
|
# restore source
|
||||||
if [ ! -d "$final_path" ]; then
|
if [ ! -d "$install_dir" ]; then
|
||||||
ynh_restore_file "$final_path"
|
ynh_restore_file "$install_dir"
|
||||||
else
|
else
|
||||||
ynh_die "There is already a directory: $final_path"
|
ynh_die "There is already a directory: $install_dir"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# restore data
|
# restore data
|
||||||
|
@ -52,7 +52,7 @@ else
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# restore port
|
# restore port
|
||||||
[ $port -eq $(ynh_find_port $port) ] || ynh_die "$port is not available, please use an other port"
|
#REMOVEME? [ $port -eq $(ynh_find_port $port) ] || ynh_die "$port is not available, please use an other port"
|
||||||
ynh_exec_fully_quiet yunohost firewall allow TCP $port
|
ynh_exec_fully_quiet yunohost firewall allow TCP $port
|
||||||
|
|
||||||
# add service in admin panel
|
# add service in admin panel
|
||||||
|
|
|
@ -4,22 +4,22 @@ source _common.sh
|
||||||
source /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
# manage script failure
|
# manage script failure
|
||||||
ynh_abort_if_errors
|
#REMOVEME? ynh_abort_if_errors
|
||||||
|
|
||||||
# retrieve arguments
|
# retrieve arguments
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
#REMOVEME? app=$YNH_APP_INSTANCE_NAME
|
||||||
domain=$(ynh_app_setting_get $app domain)
|
#REMOVEME? domain=$(ynh_app_setting_get $app domain)
|
||||||
port=$(ynh_app_setting_get $app port)
|
#REMOVEME? port=$(ynh_app_setting_get $app port)
|
||||||
is_public=$(ynh_app_setting_get $app is_public)
|
#REMOVEME? #REMOVEME? is_public=$(ynh_app_setting_get $app is_public)
|
||||||
|
|
||||||
# definie useful vars
|
# definie useful vars
|
||||||
final_path="/opt/yunohost/$app"
|
#REMOVEME? install_dir="/opt/yunohost/$app"
|
||||||
|
|
||||||
# use prior backup and restore on error only if backup feature exists on installed instance
|
# use prior backup and restore on error only if backup feature exists on installed instance
|
||||||
if [ -f "/etc/yunohost/apps/$app/scripts/backup" ] ; then
|
if [ -f "/etc/yunohost/apps/$app/scripts/backup" ] ; then
|
||||||
ynh_backup_before_upgrade # Backup the current version of the app
|
#REMOVEME? ynh_backup_before_upgrade # Backup the current version of the app
|
||||||
ynh_clean_setup () {
|
#REMOVEME? ynh_clean_setup () {
|
||||||
ynh_restore_upgradebackup
|
#REMOVEME? ynh_restore_upgradebackup
|
||||||
}
|
}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@ myynh_create_dir "/etc/sudoers.d"
|
||||||
cp "../conf/sudoers" "/etc/sudoers.d/$app"
|
cp "../conf/sudoers" "/etc/sudoers.d/$app"
|
||||||
|
|
||||||
# add required packages
|
# add required packages
|
||||||
ynh_install_app_dependencies "$PKG_DEPENDENCIES"
|
#REMOVEME? ynh_install_app_dependencies "$PKG_DEPENDENCIES"
|
||||||
|
|
||||||
# stop systemd service
|
# stop systemd service
|
||||||
ynh_system_reload --service_name="$app@$app" --action=stop
|
ynh_system_reload --service_name="$app@$app" --action=stop
|
||||||
|
@ -37,9 +37,9 @@ ynh_system_reload --service_name="$app@$app" --action=disable
|
||||||
# upgrade
|
# upgrade
|
||||||
exec_as "$app" -H -s /bin/bash -c " \
|
exec_as "$app" -H -s /bin/bash -c " \
|
||||||
echo 'create the virtual environment' \
|
echo 'create the virtual environment' \
|
||||||
&& python3 -m venv $final_path \
|
&& python3 -m venv $install_dir \
|
||||||
&& echo 'activate the virtual environment' \
|
&& echo 'activate the virtual environment' \
|
||||||
&& source $final_path/bin/activate \
|
&& source $install_dir/bin/activate \
|
||||||
&& echo 'install a required python package' \
|
&& echo 'install a required python package' \
|
||||||
&& pip install --upgrade wheel \
|
&& pip install --upgrade wheel \
|
||||||
&& echo 'install Octoprint' \
|
&& echo 'install Octoprint' \
|
||||||
|
|
Loading…
Add table
Reference in a new issue