2021-03-01 14:53:57 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# GENERIC START
|
|
|
|
#=================================================
|
|
|
|
# IMPORT GENERIC HELPERS
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
source _common.sh
|
|
|
|
source /usr/share/yunohost/helpers
|
|
|
|
|
|
|
|
#=================================================
|
2021-03-01 19:00:42 +01:00
|
|
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
2021-03-01 14:53:57 +01:00
|
|
|
#=================================================
|
2021-03-02 15:59:40 +01:00
|
|
|
ynh_script_progression --message="Setting up source files..." --weight=5
|
2021-03-01 19:00:42 +01:00
|
|
|
|
|
|
|
# Download, check integrity, uncompress and patch the source from app.src
|
2024-02-01 12:15:36 +01:00
|
|
|
ynh_setup_source --source_id="go" --dest_dir="$install_dir/go"
|
|
|
|
ynh_setup_source --source_id="lxd" --dest_dir="$install_dir/lxd"
|
2021-03-01 14:53:57 +01:00
|
|
|
|
2022-07-27 20:53:30 +02:00
|
|
|
#=================================================
|
|
|
|
# SPECIFIC SETUP
|
2021-03-01 14:53:57 +01:00
|
|
|
#=================================================
|
2021-03-01 19:00:42 +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 12:15:36 +01:00
|
|
|
pushd "$install_dir/lxd"
|
2024-02-01 15:50:28 +01:00
|
|
|
(
|
|
|
|
export PATH="$install_dir/go/bin:$PATH"
|
|
|
|
export GOPATH="$install_dir/lxd/vendor/"
|
|
|
|
export HOME=${HOME:-"/root/"}
|
|
|
|
|
|
|
|
ynh_exec_warn_less make deps
|
|
|
|
export CGO_CFLAGS="-I${GOPATH}/raft/include/ -I${GOPATH}/dqlite/include/"
|
|
|
|
export CGO_LDFLAGS="-L${GOPATH}/raft/.libs -L${GOPATH}/dqlite/.libs/"
|
|
|
|
export LD_LIBRARY_PATH="${GOPATH}/raft/.libs/:${GOPATH}/dqlite/.libs/"
|
|
|
|
export CGO_LDFLAGS_ALLOW="(-Wl,-wrap,pthread_create)|(-Wl,-z,now)"
|
|
|
|
|
|
|
|
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 $install_dir/lxd/scripts/bash/lxd-client /etc/bash_completion.d/
|
|
|
|
)
|
2021-03-01 19:00:42 +01:00
|
|
|
popd
|
2021-03-01 14:53:57 +01:00
|
|
|
|
2024-02-01 12:15:36 +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 12:15:36 +01:00
|
|
|
# SYSTEM CONFIGURATION
|
2022-07-27 20:53:30 +02:00
|
|
|
#=================================================
|
2024-02-01 12:15:36 +01:00
|
|
|
ynh_script_progression --message="Adding 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 12:15:36 +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
|
|
|
|
|
|
|
# Start a systemd service
|
2024-02-01 12:15:36 +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="Installation of $app completed" --last
|