mirror of
https://github.com/YunoHost-Apps/lxd_ynh.git
synced 2024-09-03 19:45:53 +02:00
Handle dnsmasq, ld.so, subuids as system configuration
This commit is contained in:
parent
733218bfcb
commit
b90dd0295e
7 changed files with 105 additions and 112 deletions
2
conf/dnsmasq.conf
Normal file
2
conf/dnsmasq.conf
Normal file
|
@ -0,0 +1,2 @@
|
|||
bind-interfaces
|
||||
except-interface=lxdbr0
|
1
conf/ld.so.conf
Normal file
1
conf/ld.so.conf
Normal file
|
@ -0,0 +1 @@
|
|||
/usr/local/lib/__APP__/
|
|
@ -93,6 +93,53 @@ ynh_remove_systemd_socket_config () {
|
|||
fi
|
||||
}
|
||||
|
||||
_ynh_add_dnsmasq() {
|
||||
# Declare an array to define the options of this helper.
|
||||
local legacy_args=t
|
||||
local -A args_array=( [t]=template= )
|
||||
local template
|
||||
ynh_handle_getopts_args "$@"
|
||||
local template="${template:-dnsmasq.conf}"
|
||||
|
||||
ynh_add_config --template="$template" --destination="/etc/dnsmasq.d/$app"
|
||||
|
||||
ynh_systemd_action --service_name=dnsmasq --action=restart
|
||||
}
|
||||
|
||||
_ynh_remove_dnsmasq() {
|
||||
ynh_secure_remove --file="/etc/dnsmasq.d/$app"
|
||||
|
||||
ynh_systemd_action --service_name=dnsmasq --action=restart
|
||||
}
|
||||
|
||||
_ynh_add_ld_so() {
|
||||
# Declare an array to define the options of this helper.
|
||||
local legacy_args=t
|
||||
local -A args_array=( [t]=template= )
|
||||
local template
|
||||
ynh_handle_getopts_args "$@"
|
||||
local template="${template:-ld.so.conf}"
|
||||
|
||||
ynh_add_config --template="$template" --destination="/etc/ld.so.conf.d/$app.conf"
|
||||
|
||||
ldconfig
|
||||
}
|
||||
|
||||
_ynh_remove_ld_so() {
|
||||
ynh_secure_remove --file="/etc/ld.so.conf.d/$app.conf"
|
||||
|
||||
ldconfig
|
||||
}
|
||||
|
||||
_ynh_set_subuid_subgid() {
|
||||
echo "# Added by lxd
|
||||
root:100000:65536" | tee -a /etc/subuid /etc/subgid
|
||||
}
|
||||
|
||||
_ynh_unset_subuid_subgid() {
|
||||
sed -i "/# Added by lxd$/{N;/root:100000:65536/d}" /etc/sub{u,g}id
|
||||
}
|
||||
|
||||
#=================================================
|
||||
# EXPERIMENTAL HELPERS
|
||||
#=================================================
|
||||
|
|
|
@ -9,22 +9,6 @@
|
|||
source _common.sh
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
#=================================================
|
||||
# MANAGE SCRIPT FAILURE
|
||||
#=================================================
|
||||
|
||||
ynh_clean_setup () {
|
||||
ynh_exec_warn_less popd
|
||||
|
||||
ynh_secure_remove --file="$go_tmp"
|
||||
ynh_secure_remove --file="$lxd_tmp"
|
||||
}
|
||||
|
||||
#=================================================
|
||||
# STORE SETTINGS FROM MANIFEST
|
||||
#=================================================
|
||||
ynh_script_progression --message="Storing installation settings..."
|
||||
|
||||
#=================================================
|
||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||
#=================================================
|
||||
|
@ -32,13 +16,8 @@ ynh_script_progression --message="Setting up source files..." --weight=5
|
|||
|
||||
# Download, check integrity, uncompress and patch the source from app.src
|
||||
ynh_setup_source --source_id="go" --dest_dir="$install_dir/go"
|
||||
|
||||
export PATH="$install_dir/go/bin:$PATH"
|
||||
|
||||
ynh_setup_source --source_id="lxd" --dest_dir="$install_dir/lxd"
|
||||
|
||||
export GOPATH="$install_dir/lxd/vendor/"
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC SETUP
|
||||
#=================================================
|
||||
|
@ -47,6 +26,9 @@ export GOPATH="$install_dir/lxd/vendor/"
|
|||
ynh_script_progression --message="Building lxd from sources..." --weight=60
|
||||
|
||||
pushd "$install_dir/lxd"
|
||||
(
|
||||
export PATH="$install_dir/go/bin:$PATH"
|
||||
export GOPATH="$install_dir/lxd/vendor/"
|
||||
export HOME=${HOME:-"/root/"}
|
||||
|
||||
ynh_exec_warn_less make deps
|
||||
|
@ -62,32 +44,12 @@ pushd "$install_dir/lxd"
|
|||
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/
|
||||
)
|
||||
popd
|
||||
|
||||
ynh_secure_remove --file="$install_dir/go"
|
||||
ynh_secure_remove --file="$install_dir/lxd"
|
||||
|
||||
#=================================================
|
||||
# ADD A CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Adding a configuration file..."
|
||||
|
||||
# TODO: handle this as a system config
|
||||
echo "bind-interfaces
|
||||
except-interface=lxdbr0" > /etc/dnsmasq.d/lxd
|
||||
systemctl restart dnsmasq
|
||||
|
||||
ynh_store_file_checksum --file="/etc/dnsmasq.d/lxd"
|
||||
|
||||
# TODO: handle this as a system config
|
||||
echo "/usr/local/lib/$app/" > /etc/ld.so.conf.d/$app.conf
|
||||
ynh_store_file_checksum --file="/etc/ld.so.conf.d/$app.conf"
|
||||
|
||||
ldconfig
|
||||
|
||||
echo "# Added by lxd
|
||||
root:100000:65536" | tee -a /etc/subuid /etc/subgid
|
||||
|
||||
#=================================================
|
||||
# SYSTEM CONFIGURATION
|
||||
#=================================================
|
||||
|
@ -95,10 +57,16 @@ ynh_script_progression --message="Adding system configurations related to $app..
|
|||
|
||||
# Create a dedicated systemd config
|
||||
ynh_add_systemd_socket_config
|
||||
ynh_add_systemd_config
|
||||
|
||||
ynh_add_systemd_config
|
||||
yunohost service add "$app" --log="/var/log/$app/$app.log"
|
||||
|
||||
_ynh_add_dnsmasq
|
||||
|
||||
_ynh_add_ld_so
|
||||
|
||||
_ynh_set_subuid_subgid
|
||||
|
||||
#=================================================
|
||||
# START SYSTEMD SERVICE
|
||||
#=================================================
|
||||
|
|
|
@ -23,6 +23,12 @@ fi
|
|||
ynh_exec_warn_less ynh_remove_systemd_socket_config
|
||||
ynh_exec_warn_less ynh_remove_systemd_config
|
||||
|
||||
_ynh_remove_ld_so
|
||||
|
||||
_ynh_unset_subuid_subgid
|
||||
|
||||
_ynh_remove_dnsmasq
|
||||
|
||||
#=================================================
|
||||
# REMOVE CONTAINERS
|
||||
#=================================================
|
||||
|
@ -47,10 +53,6 @@ fi
|
|||
#=================================================
|
||||
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"
|
||||
|
||||
# Remove the log files
|
||||
|
@ -66,12 +68,6 @@ ynh_secure_remove --file="/usr/local/bin/lxd-migrate"
|
|||
ynh_secure_remove --file="/usr/local/bin/lxd-user"
|
||||
ynh_secure_remove --file="/etc/bash_completion.d/lxd-client"
|
||||
|
||||
sed -i "/# Added by lxd$/{N;/root:100000:65536/d}" /etc/sub{u,g}id
|
||||
|
||||
ynh_secure_remove --file="/etc/dnsmasq.d/lxd"
|
||||
|
||||
systemctl restart dnsmasq
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
|
|
@ -10,6 +10,25 @@
|
|||
source ../settings/scripts/_common.sh
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
#=================================================
|
||||
# RESTORE SYSTEM CONFIGURATIONS
|
||||
#=================================================
|
||||
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
|
||||
|
||||
yunohost service add "$app" --log="/var/log/$app/$app.log"
|
||||
|
||||
ynh_restore_file --origin_path="/etc/dnsmasq.d/lxd"
|
||||
systemctl restart dnsmasq
|
||||
|
||||
ynh_restore_file --origin_path="/etc/ld.so.conf.d/$app.conf"
|
||||
ldconfig
|
||||
|
||||
_ynh_set_subuid_subgid
|
||||
|
||||
#=================================================
|
||||
# RESTORE VARIOUS FILES
|
||||
#=================================================
|
||||
|
@ -29,28 +48,6 @@ ynh_restore_file --origin_path="/usr/local/bin/lxd-migrate"
|
|||
ynh_restore_file --origin_path="/usr/local/bin/lxd-user"
|
||||
ynh_restore_file --origin_path="/etc/bash_completion.d/lxd-client"
|
||||
|
||||
ynh_restore_file --origin_path="/etc/dnsmasq.d/lxd"
|
||||
|
||||
systemctl restart dnsmasq
|
||||
|
||||
ynh_restore_file --origin_path="/etc/ld.so.conf.d/$app.conf"
|
||||
|
||||
ldconfig
|
||||
|
||||
echo "# Added by lxd
|
||||
root:100000:65536" | tee -a /etc/subuid /etc/subgid
|
||||
|
||||
#=================================================
|
||||
# RESTORE SYSTEM CONFIGURATIONS
|
||||
#=================================================
|
||||
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
|
||||
|
||||
yunohost service add "$app" --log="/var/log/$app/$app.log"
|
||||
|
||||
#=================================================
|
||||
# START SYSTEMD SERVICE
|
||||
#=================================================
|
||||
|
|
|
@ -73,30 +73,6 @@ popd
|
|||
ynh_secure_remove --file="$install_dir/go"
|
||||
ynh_secure_remove --file="$install_dir/lxd"
|
||||
|
||||
#=================================================
|
||||
# UPDATE A CONFIG FILE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Updating a configuration file..."
|
||||
|
||||
ynh_backup_if_checksum_is_different --file="/etc/dnsmasq.d/lxd"
|
||||
|
||||
echo "bind-interfaces
|
||||
except-interface=lxdbr0" > /etc/dnsmasq.d/lxd
|
||||
systemctl restart dnsmasq
|
||||
|
||||
ynh_store_file_checksum --file="/etc/dnsmasq.d/lxd"
|
||||
|
||||
ynh_backup_if_checksum_is_different --file="/etc/ld.so.conf.d/$app.conf"
|
||||
|
||||
echo "/usr/local/lib/$app/" > /etc/ld.so.conf.d/$app.conf
|
||||
|
||||
ynh_store_file_checksum --file="/etc/ld.so.conf.d/$app.conf"
|
||||
|
||||
ldconfig
|
||||
|
||||
echo "# Added by lxd
|
||||
root:100000:65536" | tee -a /etc/subuid /etc/subgid
|
||||
|
||||
#=================================================
|
||||
# REAPPLY SYSTEM CONFIGURATIONS
|
||||
#=================================================
|
||||
|
@ -104,10 +80,16 @@ ynh_script_progression --message="Upgrading system configurations related to $ap
|
|||
|
||||
# Create a dedicated systemd config
|
||||
ynh_add_systemd_socket_config
|
||||
ynh_add_systemd_config
|
||||
|
||||
ynh_add_systemd_config
|
||||
yunohost service add "$app" --log="/var/log/$app/$app.log"
|
||||
|
||||
_ynh_add_dnsmasq
|
||||
|
||||
_ynh_add_ld_so
|
||||
|
||||
_ynh_set_subuid_subgid
|
||||
|
||||
#=================================================
|
||||
# START SYSTEMD SERVICE
|
||||
#=================================================
|
||||
|
|
Loading…
Reference in a new issue