2021-03-01 14:53:57 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# GENERIC START
|
|
|
|
#=================================================
|
|
|
|
# IMPORT GENERIC HELPERS
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
source _common.sh
|
|
|
|
source /usr/share/yunohost/helpers
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# STANDARD UPGRADE STEPS
|
|
|
|
#=================================================
|
|
|
|
# STOP SYSTEMD SERVICE
|
|
|
|
#=================================================
|
2021-03-02 15:59:40 +01:00
|
|
|
ynh_script_progression --message="Stopping a systemd service..."
|
2021-03-01 14:53:57 +01:00
|
|
|
|
2021-10-12 13:32:48 +02:00
|
|
|
ynh_systemd_action --service_name="$app.socket" --action="stop"
|
2024-02-01 14:51:55 +01:00
|
|
|
ynh_systemd_action --service_name="$app" --action="stop" --log_path="/var/log/$app/$app.log"
|
2021-03-01 14:53:57 +01:00
|
|
|
|
|
|
|
#=================================================
|
2022-07-27 20:53:30 +02:00
|
|
|
# ENSURE DOWNWARD COMPATIBILITY
|
2021-03-01 14:53:57 +01:00
|
|
|
#=================================================
|
2024-02-06 20:54:56 +01:00
|
|
|
ynh_script_progression --message="Ensuring downward compatibility..."
|
2022-07-27 20:53:30 +02:00
|
|
|
|
2024-02-01 14:51:55 +01:00
|
|
|
# Remove old file
|
|
|
|
if [ -f "/usr/local/bin/lxd-p2c" ]; then
|
|
|
|
ynh_secure_remove --file="/usr/local/bin/lxd-p2c"
|
|
|
|
fi
|
2022-07-27 20:53:30 +02:00
|
|
|
|
2024-02-01 14:51:55 +01:00
|
|
|
sed -i "/root:1000000:65536 # Added by lxd#/d" /etc/sub{u,g}id
|
2021-03-01 14:53:57 +01:00
|
|
|
|
2021-03-02 15:44:34 +01:00
|
|
|
#=================================================
|
|
|
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
|
|
|
#=================================================
|
2021-03-02 15:59:40 +01:00
|
|
|
ynh_script_progression --message="Setting up source files..."
|
2021-03-01 14:53:57 +01:00
|
|
|
|
2021-03-02 14:58:33 +01:00
|
|
|
# Download, check integrity, uncompress and patch the source from app.src
|
2024-02-01 14:51:55 +01:00
|
|
|
ynh_setup_source --source_id="go" --dest_dir="$install_dir/go" --full_replace=1
|
2021-03-02 14:58:33 +01:00
|
|
|
|
2024-02-01 14:51:55 +01:00
|
|
|
export PATH="$install_dir/go/bin:$PATH"
|
2021-03-01 14:53:57 +01:00
|
|
|
|
2024-07-14 17:37:55 +02:00
|
|
|
ynh_setup_source --source_id="main" --dest_dir="$install_dir/lxd" --full_replace=1
|
2021-03-01 14:53:57 +01:00
|
|
|
|
2024-02-01 14:51:55 +01:00
|
|
|
export GOPATH="$install_dir/lxd/vendor/"
|
2022-07-27 20:53:30 +02:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# SPECIFIC UPGRADE
|
2021-03-01 14:53:57 +01:00
|
|
|
#=================================================
|
2021-03-02 14:58:33 +01:00
|
|
|
# BUILD FROM SOURCES
|
2021-03-01 14:53:57 +01:00
|
|
|
#=================================================
|
2021-03-02 15:59:40 +01:00
|
|
|
ynh_script_progression --message="Building lxd from sources..." --weight=60
|
2021-03-01 14:53:57 +01:00
|
|
|
|
2024-02-01 14:51:55 +01:00
|
|
|
pushd "$install_dir/lxd"
|
2022-07-27 20:53:30 +02:00
|
|
|
export HOME=${HOME:-"/root/"}
|
2021-03-02 14:58:33 +01:00
|
|
|
|
2022-07-27 20:53:30 +02:00
|
|
|
ynh_exec_warn_less make deps
|
2024-07-14 20:27:22 +02:00
|
|
|
export CGO_CFLAGS="-I${GOPATH}dqlite/include/"
|
|
|
|
export CGO_LDFLAGS="-L${GOPATH}dqlite/.libs/"
|
|
|
|
export LD_LIBRARY_PATH="${GOPATH}dqlite/.libs/"
|
2022-07-27 20:53:30 +02:00
|
|
|
export CGO_LDFLAGS_ALLOW="(-Wl,-wrap,pthread_create)|(-Wl,-z,now)"
|
2021-03-02 14:58:33 +01:00
|
|
|
|
2022-07-27 20:53:30 +02:00
|
|
|
ynh_exec_warn_less make
|
2021-03-02 14:58:33 +01:00
|
|
|
|
2022-07-27 20:53:30 +02:00
|
|
|
mkdir -p /usr/local/lib/$app
|
|
|
|
mkdir -p /var/log/$app
|
2024-07-14 20:27:22 +02:00
|
|
|
cp -a ${GOPATH}/dqlite/.libs/lib*.so* /usr/local/lib/$app/
|
2022-07-27 20:53:30 +02:00
|
|
|
cp ${GOPATH}/bin/{fuidshift,lxc,lxc-to-lxd,lxd,lxd-agent,lxd-benchmark,lxd-migrate,lxd-user} /usr/local/bin
|
2024-02-01 14:51:55 +01:00
|
|
|
cp $install_dir/lxd/scripts/bash/lxd-client /etc/bash_completion.d/
|
2021-03-02 14:58:33 +01:00
|
|
|
popd
|
|
|
|
|
2024-02-01 14:51:55 +01:00
|
|
|
ynh_secure_remove --file="$install_dir/go"
|
|
|
|
ynh_secure_remove --file="$install_dir/lxd"
|
2021-03-01 14:53:57 +01:00
|
|
|
|
2022-07-27 20:53:30 +02:00
|
|
|
#=================================================
|
2024-02-01 14:51:55 +01:00
|
|
|
# REAPPLY SYSTEM CONFIGURATIONS
|
2022-07-27 20:53:30 +02:00
|
|
|
#=================================================
|
2024-02-01 14:51:55 +01:00
|
|
|
ynh_script_progression --message="Upgrading system configurations related to $app..." --weight=1
|
2022-07-27 20:53:30 +02:00
|
|
|
|
|
|
|
# Create a dedicated systemd config
|
|
|
|
ynh_add_systemd_socket_config
|
|
|
|
|
2024-02-01 15:50:28 +01:00
|
|
|
ynh_add_systemd_config
|
2024-02-01 14:51:55 +01:00
|
|
|
yunohost service add "$app" --log="/var/log/$app/$app.log"
|
2021-03-01 14:53:57 +01:00
|
|
|
|
2024-02-01 15:50:28 +01:00
|
|
|
_ynh_add_dnsmasq
|
|
|
|
|
|
|
|
_ynh_add_ld_so
|
|
|
|
|
|
|
|
_ynh_set_subuid_subgid
|
|
|
|
|
2021-03-01 14:53:57 +01:00
|
|
|
#=================================================
|
|
|
|
# START SYSTEMD SERVICE
|
|
|
|
#=================================================
|
2021-03-02 15:59:40 +01:00
|
|
|
ynh_script_progression --message="Starting a systemd service..."
|
2021-03-01 14:53:57 +01:00
|
|
|
|
2024-02-01 14:51:55 +01:00
|
|
|
ynh_systemd_action --service_name="$app" --action="start" --log_path="/var/log/$app/$app.log"
|
2021-03-01 14:53:57 +01:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# END OF SCRIPT
|
|
|
|
#=================================================
|
|
|
|
|
2021-03-02 15:59:40 +01:00
|
|
|
ynh_script_progression --message="Upgrade of $app completed" --last
|