1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/lxd_ynh.git synced 2024-09-03 19:45:53 +02:00

Update packaging v2

This commit is contained in:
Félix Piédallu 2024-02-01 14:51:55 +01:00
parent fdb943fdc7
commit d3c8e7c3bf
5 changed files with 32 additions and 180 deletions

View file

@ -17,11 +17,11 @@ website = "https://linuxcontainers.org/lxd/"
demo = "https://linuxcontainers.org/lxd/try-it/"
admindoc = "https://linuxcontainers.org/lxd/docs/master/index.html"
code = "https://github.com/canonical/lxd"
cpe = "???"
cpe = "cpe:2.3:a:canonical:lxd"
[integration]
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"]
architectures = "all"
multi_instance = false
ldap = "not_relevant"
sso = "not_relevant"

View file

@ -10,23 +10,6 @@
source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers
#=================================================
# MANAGE SCRIPT FAILURE
#=================================================
ynh_clean_setup () {
true
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#=================================================
# LOAD SETTINGS
#=================================================
ynh_print_info --message="Loading installation settings..."
app=$YNH_APP_INSTANCE_NAME
#=================================================
# DECLARE DATA AND CONF FILES TO BACKUP
#=================================================

View file

@ -10,30 +10,15 @@ source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# LOAD SETTINGS
#=================================================
ynh_script_progression --message="Loading installation settings..."
app=$YNH_APP_INSTANCE_NAME
#=================================================
# 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..."
yunohost service remove $app
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_exec_warn_less ynh_remove_systemd_socket_config
ynh_exec_warn_less ynh_remove_systemd_config
@ -41,28 +26,16 @@ ynh_exec_warn_less ynh_remove_systemd_config
#=================================================
# REMOVE CONTAINERS
#=================================================
# Remove the data directory if --purge option is used
if [ "${YNH_APP_PURGE:-0}" -eq 1 ]
then
if [ "${YNH_APP_PURGE:-0}" -eq 1 ]; then
ynh_script_progression --message="Removing containers..."
ynh_secure_remove --file="/var/lib/lxd"
fi
#=================================================
# REMOVE DEPENDENCIES
#=================================================
ynh_script_progression --message="Removing dependencies..." --weight=20
# Remove metapackage and its dependencies
ynh_exec_warn_less ynh_remove_app_dependencies
#=================================================
# CLOSE A PORT
#=================================================
if yunohost firewall list | grep -q "\- 67$"
then
if yunohost firewall list | grep -q "\- 67$"; then
ynh_script_progression --message="Closing port 67..."
ynh_exec_warn_less yunohost firewall disallow Both 67
fi
@ -76,7 +49,6 @@ ynh_script_progression --message="Removing various files..."
# Remove a directory securely
ynh_secure_remove --file="/etc/ld.so.conf.d/$app.conf"
ldconfig
ynh_secure_remove --file="/usr/local/lib/$app"
@ -100,16 +72,6 @@ ynh_secure_remove --file="/etc/dnsmasq.d/lxd"
systemctl restart dnsmasq
#=================================================
# GENERIC FINALIZATION
#=================================================
# REMOVE DEDICATED USER
#=================================================
ynh_script_progression --message="Removing the dedicated system user..."
# Delete a system user
ynh_system_user_delete --username=$app
#=================================================
# END OF SCRIPT
#=================================================

View file

@ -10,43 +10,6 @@
source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers
#=================================================
# MANAGE SCRIPT FAILURE
#=================================================
ynh_clean_setup () {
ynh_clean_check_starting
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#=================================================
# LOAD SETTINGS
#=================================================
ynh_script_progression --message="Loading installation settings..."
app=$YNH_APP_INSTANCE_NAME
#=================================================
# STANDARD RESTORATION STEPS
#=================================================
# RECREATE THE DEDICATED USER
#=================================================
ynh_script_progression --message="Recreating the dedicated system user..."
# Create the dedicated user (if not existing)
ynh_system_user_create --username=$app
#=================================================
# SPECIFIC RESTORATION
#=================================================
# REINSTALL DEPENDENCIES
#=================================================
ynh_script_progression --message="Reinstalling dependencies..." --weight=30
# Define and install dependencies
ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies
#=================================================
# RESTORE VARIOUS FILES
#=================================================
@ -78,27 +41,22 @@ echo "# Added by lxd
root:100000:65536" | tee -a /etc/subuid /etc/subgid
#=================================================
# 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/systemd/system/$app.service"
ynh_restore_file --origin_path="/etc/systemd/system/$app.socket"
systemctl enable $app.service --quiet
systemctl enable "$app.service" --quiet
#=================================================
# INTEGRATE SERVICE IN YUNOHOST
#=================================================
ynh_script_progression --message="Integrating service in YunoHost..."
yunohost service add $app --log="/var/log/$app/$app.log"
yunohost service add "$app" --log="/var/log/$app/$app.log"
#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Starting a systemd service..."
ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log"
ynh_systemd_action --service_name="$app" --action="start" --log_path="/var/log/$app/$app.log"
#=================================================
# END OF SCRIPT

View file

@ -9,36 +9,6 @@
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# LOAD SETTINGS
#=================================================
ynh_script_progression --message="Loading installation settings..."
app=$YNH_APP_INSTANCE_NAME
#=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
#=================================================
ynh_script_progression --message="Backing up the app before upgrading (may take a while)..."
# Backup the current version of the app
ynh_backup_before_upgrade
ynh_clean_setup () {
ynh_exec_warn_less popd
ynh_secure_remove --file="$go_tmp"
ynh_secure_remove --file="$lxd_tmp"
# Restore it if the upgrade fails
ynh_restore_upgradebackup
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
# Remove old file
if [ -f "/usr/local/bin/lxd-p2c" ]; then
ynh_secure_remove --file="/usr/local/bin/lxd-p2c"
fi
#=================================================
# STANDARD UPGRADE STEPS
#=================================================
@ -47,45 +17,33 @@ fi
ynh_script_progression --message="Stopping a systemd service..."
ynh_systemd_action --service_name="$app.socket" --action="stop"
ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log"
ynh_systemd_action --service_name="$app" --action="stop" --log_path="/var/log/$app/$app.log"
#=================================================
# ENSURE DOWNWARD COMPATIBILITY
#=================================================
ynh_script_progression --message="Ensuring downward compatibility..."
ynh_script_progression --message="Ensuring downward compatibility..." --weight=1
# Remove old file
if [ -f "/usr/local/bin/lxd-p2c" ]; then
ynh_secure_remove --file="/usr/local/bin/lxd-p2c"
fi
sed -i "/root:1000000:65536 # Added by lxd#/d" /etc/sub{u,g}id
#=================================================
# CREATE DEDICATED USER
#=================================================
ynh_script_progression --message="Making sure dedicated system user exists..."
# Create a dedicated user (if not existing)
ynh_system_user_create --username=$app
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
ynh_script_progression --message="Setting up source files..."
# Download, check integrity, uncompress and patch the source from app.src
go_tmp=$(mktemp -d)
ynh_setup_source --dest_dir="$go_tmp" --source_id="go.$YNH_ARCH"
ynh_setup_source --source_id="go" --dest_dir="$install_dir/go" --full_replace=1
export PATH=$go_tmp/bin:$PATH
export PATH="$install_dir/go/bin:$PATH"
lxd_tmp=$(mktemp -d)
ynh_setup_source --dest_dir="$lxd_tmp" --source_id="lxd"
ynh_setup_source --source_id="lxd" --dest_dir="$install_dir/lxd" --full_replace=1
export GOPATH=${lxd_tmp}/vendor/
#=================================================
# UPGRADE DEPENDENCIES
#=================================================
ynh_script_progression --message="Upgrading dependencies..."
ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies
export GOPATH="$install_dir/lxd/vendor/"
#=================================================
# SPECIFIC UPGRADE
@ -94,7 +52,7 @@ ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies
#=================================================
ynh_script_progression --message="Building lxd from sources..." --weight=60
pushd ${lxd_tmp}
pushd "$install_dir/lxd"
export HOME=${HOME:-"/root/"}
ynh_exec_warn_less make deps
@ -103,19 +61,17 @@ pushd ${lxd_tmp}
export LD_LIBRARY_PATH="${GOPATH}/raft/.libs/:${GOPATH}/dqlite/.libs/"
export CGO_LDFLAGS_ALLOW="(-Wl,-wrap,pthread_create)|(-Wl,-z,now)"
export GOCACHE=$go_tmp
ynh_exec_warn_less make
mkdir -p /usr/local/lib/$app
mkdir -p /var/log/$app
cp -a ${GOPATH}/{raft,dqlite}/.libs/lib*.so* /usr/local/lib/$app/
cp ${GOPATH}/bin/{fuidshift,lxc,lxc-to-lxd,lxd,lxd-agent,lxd-benchmark,lxd-migrate,lxd-user} /usr/local/bin
cp ${lxd_tmp}/scripts/bash/lxd-client /etc/bash_completion.d/
cp $install_dir/lxd/scripts/bash/lxd-client /etc/bash_completion.d/
popd
ynh_secure_remove --file="$go_tmp"
ynh_secure_remove --file="$lxd_tmp"
ynh_secure_remove --file="$install_dir/go"
ynh_secure_remove --file="$install_dir/lxd"
#=================================================
# UPDATE A CONFIG FILE
@ -142,29 +98,22 @@ echo "# Added by lxd
root:100000:65536" | tee -a /etc/subuid /etc/subgid
#=================================================
# SETUP SYSTEMD
# REAPPLY SYSTEM CONFIGURATIONS
#=================================================
ynh_script_progression --message="Upgrading systemd configuration..."
ynh_script_progression --message="Upgrading system configurations related to $app..." --weight=1
# Create a dedicated systemd config
ynh_add_systemd_socket_config
ynh_add_systemd_config
#=================================================
# GENERIC FINALIZATION
#=================================================
# INTEGRATE SERVICE IN YUNOHOST
#=================================================
ynh_script_progression --message="Integrating service in YunoHost..."
yunohost service add $app --log="/var/log/$app/$app.log"
yunohost service add "$app" --log="/var/log/$app/$app.log"
#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Starting a systemd service..."
ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log"
ynh_systemd_action --service_name="$app" --action="start" --log_path="/var/log/$app/$app.log"
#=================================================
# END OF SCRIPT