From 7b74a3b4efabba163b9ea85420c1a609c3925c16 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sat, 23 Jul 2022 04:31:09 +0200 Subject: [PATCH 1/7] bootstrap_expect --- check_process | 2 ++ conf/server.hcl | 2 +- manifest.json | 12 ++++++++++++ scripts/install | 2 ++ scripts/upgrade | 1 + 5 files changed, 18 insertions(+), 1 deletion(-) diff --git a/check_process b/check_process index 4b75a1f..0525f7b 100644 --- a/check_process +++ b/check_process @@ -3,6 +3,7 @@ domain="domain.tld" is_public=1 node_type="client" + bootstrap_expect="1" server_ip="192.168.1.100" ; Checks pkg_linter=1 @@ -22,6 +23,7 @@ domain="domain.tld" is_public=1 node_type="server" + bootstrap_expect="1" server_ip="none..." ; Checks pkg_linter=1 diff --git a/conf/server.hcl b/conf/server.hcl index 2b80785..0f937b5 100644 --- a/conf/server.hcl +++ b/conf/server.hcl @@ -8,7 +8,7 @@ server { # This is an integer representing the number of server nodes to wait for before bootstrapping. It is most # common to use the odd-numbered integers 3 or 5 for this value, depending on the cluster size. A value of # 1 does not provide any fault tolerance and is not recommended for production use cases. - bootstrap_expect = 1 + bootstrap_expect = __BOOTSTRAP_EXPECT__ # This is the data directory used for server-specific data, including the replicated log. By default, this # directory lives inside of the data_dir in the "server" sub-path. diff --git a/manifest.json b/manifest.json index 5e0561f..6581c06 100644 --- a/manifest.json +++ b/manifest.json @@ -45,6 +45,18 @@ "choices": ["server", "client"], "default": "server" }, + { + "name": "bootstrap_expect", + "type": "string", + "ask": { + "en": "[Server only] How many server nodes to wait for before bootstrapping ?" + }, + "choices": ["1", "3", "5", "7", "9"], + "default": "1", + "help": { + "en": "For production, it's recommanded to have 3 to 5 server nodes." + } + }, { "name": "server_ip", "type": "string", diff --git a/scripts/install b/scripts/install index fb436dc..686e9a2 100755 --- a/scripts/install +++ b/scripts/install @@ -28,6 +28,7 @@ domain=$YNH_APP_ARG_DOMAIN path_url="/" is_public=$YNH_APP_ARG_IS_PUBLIC node_type=$YNH_APP_ARG_NODE_TYPE +bootstrap_expect=$YNH_APP_ARG_BOOTSTRAP_EXPECT server_ip=$YNH_APP_ARG_SERVER_IP app=$YNH_APP_INSTANCE_NAME @@ -52,6 +53,7 @@ ynh_script_progression --message="Storing installation settings..." ynh_app_setting_set --app=$app --key=domain --value=$domain ynh_app_setting_set --app=$app --key=path --value=$path_url ynh_app_setting_set --app=$app --key=node_type --value=$node_type +ynh_app_setting_set --app=$app --key=bootstrap_expect --value=$bootstrap_expect ynh_app_setting_set --app=$app --key=server_ip --value=$server_ip ynh_app_setting_set --app=$app --key=lxc_bridge --value=$lxc_bridge ynh_app_setting_set --app=$app --key=plage_ip --value=$plage_ip diff --git a/scripts/upgrade b/scripts/upgrade index 9fcf541..e54f780 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -23,6 +23,7 @@ config_path=$(ynh_app_setting_get --app=$app --key=config_path) datadir=$(ynh_app_setting_get --app=$app --key=datadir) node_type=$(ynh_app_setting_get --app=$app --key=node_type) server_ip=$(ynh_app_setting_get --app=$app --key=server_ip) +bootstrap_expect=$(ynh_app_setting_get --app=$app --key=bootstrap_expect) http_port=$(ynh_app_setting_get --app=$app --key=http_port) rpc_port=$(ynh_app_setting_get --app=$app --key=rpc_port) serf_port=$(ynh_app_setting_get --app=$app --key=serf_port) From ba83dc8281f50f7d7ee977db6a5398a72127f102 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sat, 23 Jul 2022 04:35:37 +0200 Subject: [PATCH 2/7] Retry_join --- check_process | 2 ++ conf/server.hcl | 2 +- manifest.json | 9 +++++++++ scripts/install | 2 ++ scripts/upgrade | 3 ++- 5 files changed, 16 insertions(+), 2 deletions(-) diff --git a/check_process b/check_process index 0525f7b..8d574fc 100644 --- a/check_process +++ b/check_process @@ -4,6 +4,7 @@ is_public=1 node_type="client" bootstrap_expect="1" + retry_join="192.168.1.100" server_ip="192.168.1.100" ; Checks pkg_linter=1 @@ -24,6 +25,7 @@ is_public=1 node_type="server" bootstrap_expect="1" + retry_join="192.168.1.100" server_ip="none..." ; Checks pkg_linter=1 diff --git a/conf/server.hcl b/conf/server.hcl index 0f937b5..7310a15 100644 --- a/conf/server.hcl +++ b/conf/server.hcl @@ -38,7 +38,7 @@ server { # Similar to start_join but allows retrying a join if the first attempt fails. This is useful for cases # where we know the address will become available eventually. -# retry_join = [] + retry_join = ["__RETRY_JOIN__"] # The time to wait between join attempts. Defaults to 30s. retry_interval = "30s" diff --git a/manifest.json b/manifest.json index 6581c06..89ee8f3 100644 --- a/manifest.json +++ b/manifest.json @@ -57,6 +57,15 @@ "en": "For production, it's recommanded to have 3 to 5 server nodes." } }, + { + "name": "retry_join", + "type": "string", + "ask": { + "en": "[Server only] What is the IP of another server to join ?" + }, + "example": "192.168.1.100", + "optional": true + }, { "name": "server_ip", "type": "string", diff --git a/scripts/install b/scripts/install index 686e9a2..2335f96 100755 --- a/scripts/install +++ b/scripts/install @@ -29,6 +29,7 @@ path_url="/" is_public=$YNH_APP_ARG_IS_PUBLIC node_type=$YNH_APP_ARG_NODE_TYPE bootstrap_expect=$YNH_APP_ARG_BOOTSTRAP_EXPECT +retry_join=$YNH_APP_ARG_RETRY_JOIN server_ip=$YNH_APP_ARG_SERVER_IP app=$YNH_APP_INSTANCE_NAME @@ -54,6 +55,7 @@ ynh_app_setting_set --app=$app --key=domain --value=$domain ynh_app_setting_set --app=$app --key=path --value=$path_url ynh_app_setting_set --app=$app --key=node_type --value=$node_type ynh_app_setting_set --app=$app --key=bootstrap_expect --value=$bootstrap_expect +ynh_app_setting_set --app=$app --key=retry_join --value=$retry_join ynh_app_setting_set --app=$app --key=server_ip --value=$server_ip ynh_app_setting_set --app=$app --key=lxc_bridge --value=$lxc_bridge ynh_app_setting_set --app=$app --key=plage_ip --value=$plage_ip diff --git a/scripts/upgrade b/scripts/upgrade index e54f780..f75b4c0 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -22,8 +22,9 @@ path_url=$(ynh_app_setting_get --app=$app --key=path) config_path=$(ynh_app_setting_get --app=$app --key=config_path) datadir=$(ynh_app_setting_get --app=$app --key=datadir) node_type=$(ynh_app_setting_get --app=$app --key=node_type) -server_ip=$(ynh_app_setting_get --app=$app --key=server_ip) bootstrap_expect=$(ynh_app_setting_get --app=$app --key=bootstrap_expect) +retry_join=$(ynh_app_setting_get --app=$app --key=retry_join) +server_ip=$(ynh_app_setting_get --app=$app --key=server_ip) http_port=$(ynh_app_setting_get --app=$app --key=http_port) rpc_port=$(ynh_app_setting_get --app=$app --key=rpc_port) serf_port=$(ynh_app_setting_get --app=$app --key=serf_port) From 700cb2ac758fd377490534a881858497e05ad9f6 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sat, 23 Jul 2022 04:57:16 +0200 Subject: [PATCH 3/7] LXC driver --- check_process | 2 ++ manifest.json | 20 ++++++++++++++ scripts/_common.sh | 5 +++- scripts/install | 67 +++++++++++++++++++++++++++++----------------- scripts/remove | 20 ++++++++------ scripts/restore | 38 +++++++++++++++++--------- scripts/upgrade | 52 ++++++++++++++++++++++------------- 7 files changed, 139 insertions(+), 65 deletions(-) diff --git a/check_process b/check_process index 8d574fc..0d02bbf 100644 --- a/check_process +++ b/check_process @@ -6,6 +6,7 @@ bootstrap_expect="1" retry_join="192.168.1.100" server_ip="192.168.1.100" + driver_lxc=1 ; Checks pkg_linter=1 setup_sub_dir=0 @@ -27,6 +28,7 @@ bootstrap_expect="1" retry_join="192.168.1.100" server_ip="none..." + driver_lxc=1 ; Checks pkg_linter=1 setup_sub_dir=0 diff --git a/manifest.json b/manifest.json index 89ee8f3..fb5c379 100644 --- a/manifest.json +++ b/manifest.json @@ -74,6 +74,26 @@ }, "example": "192.168.1.100", "optional": true + }, + { + "name": "server_ip", + "type": "string", + "ask": { + "en": "[Client only] What is the IP of the Nomad server node ?" + }, + "example": "192.168.1.100", + "optional": true + }, + { + "name": "driver_lxc", + "type": "boolean", + "ask": { + "en": "[Client only] Do you want to install LXC driver ?" + }, + "default": true, + "help": { + "en": "It will also install lxc." + } } ] } diff --git a/scripts/_common.sh b/scripts/_common.sh index e1a4f0d..8a15aaa 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -7,7 +7,10 @@ # dependencies used by the app pkg_dependencies="nomad" -client_pkg_dependencies="pkg-config lxc-dev lxc lxc-templates" +server_pkg_dependencies="" + +client_pkg_dependencies="" +client_lxc_pkg_dependencies="pkg-config lxc-dev lxc lxc-templates" go_version=1.15 diff --git a/scripts/install b/scripts/install index 2335f96..74ccc72 100755 --- a/scripts/install +++ b/scripts/install @@ -31,6 +31,7 @@ node_type=$YNH_APP_ARG_NODE_TYPE bootstrap_expect=$YNH_APP_ARG_BOOTSTRAP_EXPECT retry_join=$YNH_APP_ARG_RETRY_JOIN server_ip=$YNH_APP_ARG_SERVER_IP +driver_lxc=$YNH_APP_ARG_DRIVER_LXC app=$YNH_APP_INSTANCE_NAME @@ -57,6 +58,7 @@ ynh_app_setting_set --app=$app --key=node_type --value=$node_type ynh_app_setting_set --app=$app --key=bootstrap_expect --value=$bootstrap_expect ynh_app_setting_set --app=$app --key=retry_join --value=$retry_join ynh_app_setting_set --app=$app --key=server_ip --value=$server_ip +ynh_app_setting_set --app=$app --key=driver_lxc --value=$driver_lxc ynh_app_setting_set --app=$app --key=lxc_bridge --value=$lxc_bridge ynh_app_setting_set --app=$app --key=plage_ip --value=$plage_ip ynh_app_setting_set --app=$app --key=main_iface --value=$main_iface @@ -96,10 +98,19 @@ fi #================================================= ynh_script_progression --message="Installing dependencies..." +if [ "$node_type" == "server" ] +then + ynh_install_app_dependencies $server_pkg_dependencies +fi + if [ "$node_type" == "client" ] then + if [ $driver_lxc -eq 1 ] + then + $client_pkg_dependencies="$client_pkg_dependencies $client_lxc_pkg_dependencies" + ynh_install_go --go_version=$go_version + fi ynh_install_app_dependencies $client_pkg_dependencies - ynh_install_go --go_version=$go_version fi ynh_install_extra_app_dependencies --repo="deb https://apt.releases.hashicorp.com $(lsb_release -cs) main" --package="$pkg_dependencies" --key="https://apt.releases.hashicorp.com/gpg" @@ -137,27 +148,30 @@ chmod -R o-rwx "$datadir" chown -R $app:$app "$datadir" #================================================= -# BUILD LXC DRIVER +# BUILD DRIVERS #================================================= if [ "$node_type" == "client" ] then - ynh_script_progression --message="Building LXC driver..." + if [ $driver_lxc -eq 1 ] + then + ynh_script_progression --message="Building LXC driver..." - tempdir="$(mktemp -d)" - ynh_setup_source --dest_dir="$tempdir" --source_id="driver-lxc" + tempdir="$(mktemp -d)" + ynh_setup_source --dest_dir="$tempdir" --source_id="driver-lxc" - pushd $tempdir - final_path=$tempdir - ynh_use_go - export GOPATH="$tempdir/go" - export GOCACHE="$tempdir/.cache" - ynh_exec_warn_less $ynh_go build - popd + pushd $tempdir + final_path=$tempdir + ynh_use_go + export GOPATH="$tempdir/go" + export GOCACHE="$tempdir/.cache" + ynh_exec_warn_less $ynh_go build + popd - mv -f $tempdir/nomad-driver-lxc $datadir/plugins/nomad-driver-lxc + mv -f $tempdir/nomad-driver-lxc $datadir/plugins/nomad-driver-lxc - ynh_secure_remove --file="$tempdir" + ynh_secure_remove --file="$tempdir" + fi fi #================================================= @@ -189,20 +203,23 @@ then ynh_add_config --template="../conf/client.hcl" --destination="$config_path/client.hcl" chmod 400 "$config_path/client.hcl" chown $app:$app "$config_path/client.hcl" + + if [ $driver_lxc -eq 1 ] + then + ynh_add_config --template="../conf/driver-lxc.hcl" --destination="$config_path/driver-lxc.hcl" + chmod 400 "$config_path/driver-lxc.hcl" + chown $app:$app "$config_path/driver-lxc.hcl" - ynh_add_config --template="../conf/driver-lxc.hcl" --destination="$config_path/driver-lxc.hcl" - chmod 400 "$config_path/driver-lxc.hcl" - chown $app:$app "$config_path/driver-lxc.hcl" + ynh_add_config --template="../conf/dnsmasq-lxd" --destination="/etc/dnsmasq.d/lxd" + systemctl restart dnsmasq - ynh_add_config --template="../conf/dnsmasq-lxd" --destination="/etc/dnsmasq.d/lxd" - systemctl restart dnsmasq - - if [ ! ${PACKAGE_CHECK_EXEC:-0} -eq 1 ]; then - ynh_add_config --template="../conf/lxc-net" --destination="/etc/default/lxc-net" + if [ ! ${PACKAGE_CHECK_EXEC:-0} -eq 1 ]; then + ynh_add_config --template="../conf/lxc-net" --destination="/etc/default/lxc-net" + fi + ynh_add_config --template="../conf/default.conf" --destination="/etc/lxc/default.conf" + systemctl enable lxc-net --quiet + ynh_systemd_action --service_name=lxc-net --action="restart" --line_match="Started LXC network bridge" --log_path="systemd" fi - ynh_add_config --template="../conf/default.conf" --destination="/etc/lxc/default.conf" - systemctl enable lxc-net --quiet - ynh_systemd_action --service_name=lxc-net --action="restart" --line_match="Started LXC network bridge" --log_path="systemd" fi #================================================= diff --git a/scripts/remove b/scripts/remove index 1d1a119..b764c2d 100755 --- a/scripts/remove +++ b/scripts/remove @@ -20,6 +20,7 @@ domain=$(ynh_app_setting_get --app=$app --key=domain) config_path=$(ynh_app_setting_get --app=$app --key=config_path) datadir=$(ynh_app_setting_get --app=$app --key=datadir) node_type=$(ynh_app_setting_get --app=$app --key=node_type) +driver_lxc=$(ynh_app_setting_get --app=$app --key=driver_lxc) rpc_port=$(ynh_app_setting_get --app=$app --key=rpc_port) serf_port=$(ynh_app_setting_get --app=$app --key=serf_port) @@ -79,15 +80,18 @@ fi if [ "$node_type" == "client" ] then + + if [ $driver_lxc -eq 1 ] + then + lxc_bridge=$(ynh_app_setting_get --app=$app --key=lxc_bridge) - lxc_bridge=$(ynh_app_setting_get --app=$app --key=lxc_bridge) - - ynh_systemd_action --service_name=lxc-net --action="stop" - systemctl disable lxc-net --quiet - ynh_secure_remove --file="/etc/default/lxc-net" - ynh_secure_remove --file="/etc/lxc/default.conf" - ynh_secure_remove --file="/etc/dnsmasq.d/lxd" - systemctl restart dnsmasq + ynh_systemd_action --service_name=lxc-net --action="stop" + systemctl disable lxc-net --quiet + ynh_secure_remove --file="/etc/default/lxc-net" + ynh_secure_remove --file="/etc/lxc/default.conf" + ynh_secure_remove --file="/etc/dnsmasq.d/lxd" + systemctl restart dnsmasq + fi fi #================================================= diff --git a/scripts/restore b/scripts/restore index 4317a7f..fb98a2e 100755 --- a/scripts/restore +++ b/scripts/restore @@ -32,6 +32,7 @@ path_url=$(ynh_app_setting_get --app=$app --key=path) config_path=$(ynh_app_setting_get --app=$app --key=config_path) datadir=$(ynh_app_setting_get --app=$app --key=datadir) node_type=$(ynh_app_setting_get --app=$app --key=node_type) +driver_lxc=$(ynh_app_setting_get --app=$app --key=driver_lxc) http_port=$(ynh_app_setting_get --app=$app --key=http_port) rpc_port=$(ynh_app_setting_get --app=$app --key=rpc_port) serf_port=$(ynh_app_setting_get --app=$app --key=serf_port) @@ -71,8 +72,17 @@ chown -R $app:$app "$datadir" #================================================= ynh_script_progression --message="Reinstalling dependencies..." +if [ "$node_type" == "server" ] +then + ynh_install_app_dependencies $server_pkg_dependencies +fi + if [ "$node_type" == "client" ] then + if [ $driver_lxc -eq 1 ] + then + $client_pkg_dependencies="$client_pkg_dependencies $client_lxc_pkg_dependencies" + fi ynh_install_app_dependencies $client_pkg_dependencies fi ynh_install_extra_app_dependencies --repo="deb https://apt.releases.hashicorp.com $(lsb_release -cs) main" --package="$pkg_dependencies" --key="https://apt.releases.hashicorp.com/gpg" @@ -106,22 +116,24 @@ then fi if [ "$node_type" == "client" ] -then +then + if [ $driver_lxc -eq 1 ] + then + lxc_bridge=$(ynh_app_setting_get --app=$app --key=lxc_bridge) + plage_ip=$(ynh_app_setting_get --app=$app --key=plage_ip) + main_iface=$(ip route | grep default | awk '{print $5;}') + ynh_app_setting_set --app=$app --key=main_iface --value=$main_iface - lxc_bridge=$(ynh_app_setting_get --app=$app --key=lxc_bridge) - plage_ip=$(ynh_app_setting_get --app=$app --key=plage_ip) - main_iface=$(ip route | grep default | awk '{print $5;}') - ynh_app_setting_set --app=$app --key=main_iface --value=$main_iface + ynh_add_config --template="../conf/dnsmasq-lxd" --destination="/etc/dnsmasq.d/lxd" + systemctl restart dnsmasq - ynh_add_config --template="../conf/dnsmasq-lxd" --destination="/etc/dnsmasq.d/lxd" - systemctl restart dnsmasq - - if [ ! ${PACKAGE_CHECK_EXEC:-0} -eq 1 ]; then - ynh_add_config --template="../conf/lxc-net" --destination="/etc/default/lxc-net" + if [ ! ${PACKAGE_CHECK_EXEC:-0} -eq 1 ]; then + ynh_add_config --template="../conf/lxc-net" --destination="/etc/default/lxc-net" + fi + ynh_add_config --template="../conf/default.conf" --destination="/etc/lxc/default.conf" + systemctl enable lxc-net --quiet + ynh_systemd_action --service_name=lxc-net --action="restart" --line_match="Started LXC network bridge" --log_path="systemd" fi - ynh_add_config --template="../conf/default.conf" --destination="/etc/lxc/default.conf" - systemctl enable lxc-net --quiet - ynh_systemd_action --service_name=lxc-net --action="restart" --line_match="Started LXC network bridge" --log_path="systemd" fi #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index f75b4c0..6093f6c 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -25,6 +25,7 @@ node_type=$(ynh_app_setting_get --app=$app --key=node_type) bootstrap_expect=$(ynh_app_setting_get --app=$app --key=bootstrap_expect) retry_join=$(ynh_app_setting_get --app=$app --key=retry_join) server_ip=$(ynh_app_setting_get --app=$app --key=server_ip) +driver_lxc=$(ynh_app_setting_get --app=$app --key=driver_lxc) http_port=$(ynh_app_setting_get --app=$app --key=http_port) rpc_port=$(ynh_app_setting_get --app=$app --key=rpc_port) serf_port=$(ynh_app_setting_get --app=$app --key=serf_port) @@ -85,10 +86,19 @@ ynh_system_user_create --username=$app #================================================= ynh_script_progression --message="Upgrading dependencies..." +if [ "$node_type" == "server" ] +then + ynh_install_app_dependencies $server_pkg_dependencies +fi + if [ "$node_type" == "client" ] then + if [ $driver_lxc -eq 1 ] + then + $client_pkg_dependencies="$client_pkg_dependencies $client_lxc_pkg_dependencies" + ynh_install_go --go_version=$go_version + fi ynh_install_app_dependencies $client_pkg_dependencies - ynh_install_go --go_version=$go_version fi ynh_install_extra_app_dependencies --repo="deb https://apt.releases.hashicorp.com $(lsb_release -cs) main" --package="$pkg_dependencies" --key="https://apt.releases.hashicorp.com/gpg" @@ -103,27 +113,30 @@ ynh_add_nginx_config #================================================= # SPECIFIC UPGRADE #================================================= -# BUILD LXC DRIVER +# BUILD DRIVERS #================================================= if [ "$node_type" == "client" ] then - ynh_script_progression --message="Building LXC driver..." + if [ $driver_lxc -eq 1 ] + then + ynh_script_progression --message="Building LXC driver..." - tempdir="$(mktemp -d)" - ynh_setup_source --dest_dir="$tempdir" --source_id="driver-lxc" + tempdir="$(mktemp -d)" + ynh_setup_source --dest_dir="$tempdir" --source_id="driver-lxc" - pushd $tempdir - final_path=$tempdir - ynh_use_go - export GOPATH="$tempdir/go" - export GOCACHE="$tempdir/.cache" - ynh_exec_warn_less$ynh_go build - popd + pushd $tempdir + final_path=$tempdir + ynh_use_go + export GOPATH="$tempdir/go" + export GOCACHE="$tempdir/.cache" + ynh_exec_warn_less$ynh_go build + popd - mv -f $tempdir/nomad-driver-lxc $datadir/plugins/nomad-driver-lxc + mv -f $tempdir/nomad-driver-lxc $datadir/plugins/nomad-driver-lxc - ynh_secure_remove --file="$tempdir" + ynh_secure_remove --file="$tempdir" + fi fi #================================================= @@ -152,10 +165,13 @@ then ynh_add_config --template="../conf/client.hcl" --destination="$config_path/client.hcl" chmod 400 "$config_path/client.hcl" chown $app:$app "$config_path/client.hcl" - - ynh_add_config --template="../conf/driver-lxc.hcl" --destination="$config_path/driver-lxc.hcl" - chmod 400 "$config_path/driver-lxc.hcl" - chown $app:$app "$config_path/driver-lxc.hcl" + + if [ $driver_lxc -eq 1 ] + then + ynh_add_config --template="../conf/driver-lxc.hcl" --destination="$config_path/driver-lxc.hcl" + chmod 400 "$config_path/driver-lxc.hcl" + chown $app:$app "$config_path/driver-lxc.hcl" + fi fi #================================================= From 34fb3a94d47a2c42696b27cbd71146e0a66a57ea Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sat, 23 Jul 2022 05:17:02 +0200 Subject: [PATCH 4/7] typo --- scripts/install | 2 +- scripts/restore | 2 +- scripts/upgrade | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/install b/scripts/install index 13443ce..1c3289f 100644 --- a/scripts/install +++ b/scripts/install @@ -107,7 +107,7 @@ if [ "$node_type" == "client" ] then if [ $driver_lxc -eq 1 ] then - $client_pkg_dependencies="$client_pkg_dependencies $client_lxc_pkg_dependencies" + client_pkg_dependencies="$client_pkg_dependencies $client_lxc_pkg_dependencies" ynh_exec_warn_less ynh_install_go --go_version=$go_version fi ynh_install_app_dependencies $client_pkg_dependencies diff --git a/scripts/restore b/scripts/restore index fb98a2e..50c5aaa 100755 --- a/scripts/restore +++ b/scripts/restore @@ -81,7 +81,7 @@ if [ "$node_type" == "client" ] then if [ $driver_lxc -eq 1 ] then - $client_pkg_dependencies="$client_pkg_dependencies $client_lxc_pkg_dependencies" + client_pkg_dependencies="$client_pkg_dependencies $client_lxc_pkg_dependencies" fi ynh_install_app_dependencies $client_pkg_dependencies fi diff --git a/scripts/upgrade b/scripts/upgrade index 1c91bba..c48777c 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -95,7 +95,7 @@ if [ "$node_type" == "client" ] then if [ $driver_lxc -eq 1 ] then - $client_pkg_dependencies="$client_pkg_dependencies $client_lxc_pkg_dependencies" + client_pkg_dependencies="$client_pkg_dependencies $client_lxc_pkg_dependencies" ynh_exec_warn_less ynh_install_go --go_version=$go_version fi ynh_install_app_dependencies $client_pkg_dependencies From 7b1afd5ee24c354846854328886f1c8cc43972a5 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sat, 23 Jul 2022 15:58:32 +0200 Subject: [PATCH 5/7] Update remove --- scripts/remove | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/scripts/remove b/scripts/remove index 2c88020..1f58367 100755 --- a/scripts/remove +++ b/scripts/remove @@ -104,7 +104,10 @@ ynh_script_progression --message="Removing dependencies..." ynh_remove_app_dependencies if [ "$node_type" == "client" ] then - ynh_remove_go + if [ $driver_lxc -eq 1 ] + then + ynh_remove_go + fi fi #================================================= From dd981783ddca3839dd2d576369961db45c578050 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sat, 23 Jul 2022 16:56:59 +0200 Subject: [PATCH 6/7] client_lxc specific parameters --- conf/default.conf | 2 +- conf/dnsmasq-lxd | 2 +- conf/lxc-net | 8 ++++---- scripts/install | 12 ++++++------ scripts/remove | 2 +- scripts/restore | 8 ++++---- 6 files changed, 17 insertions(+), 17 deletions(-) diff --git a/conf/default.conf b/conf/default.conf index 89f8c4b..ae6ea01 100644 --- a/conf/default.conf +++ b/conf/default.conf @@ -1,5 +1,5 @@ lxc.net.0.type = veth -lxc.net.0.link = __LXC_BRIDGE__ +lxc.net.0.link = __CLIENT_LXC_BRIDGE__ lxc.net.0.flags = up lxc.net.0.hwaddr = 00:16:3e:xx:xx:xx lxc.apparmor.profile = generated diff --git a/conf/dnsmasq-lxd b/conf/dnsmasq-lxd index aa50cdd..ebadaf0 100644 --- a/conf/dnsmasq-lxd +++ b/conf/dnsmasq-lxd @@ -1,2 +1,2 @@ bind-interfaces -except-interface=__LXC_BRIDGE__ +except-interface=__CLIENT_LXC_BRIDGE__ diff --git a/conf/lxc-net b/conf/lxc-net index c19bedb..2307d88 100644 --- a/conf/lxc-net +++ b/conf/lxc-net @@ -1,9 +1,9 @@ USE_LXC_BRIDGE="true" -LXC_BRIDGE="__LXC_BRIDGE__" -LXC_ADDR="__PLAGE_IP__.1" +LXC_BRIDGE="__CLIENT_LXC_BRIDGE__" +LXC_ADDR="__CLIENT_LXC_PLAGE_IP__.1" LXC_NETMASK="255.255.255.0" -LXC_NETWORK="__PLAGE_IP__.0/24" -LXC_DHCP_RANGE="__PLAGE_IP__.2,__PLAGE_IP__.254" +LXC_NETWORK="__CLIENT_LXC_PLAGE_IP__.0/24" +LXC_DHCP_RANGE="__CLIENT_LXC_PLAGE_IP__.2,__CLIENT_LXC_PLAGE_IP__.254" LXC_DHCP_MAX="253" LXC_DHCP_CONFILE="" LXC_DOMAIN="" diff --git a/scripts/install b/scripts/install index 1c3289f..27645a0 100644 --- a/scripts/install +++ b/scripts/install @@ -35,9 +35,9 @@ driver_lxc=$YNH_APP_ARG_DRIVER_LXC app=$YNH_APP_INSTANCE_NAME -lxc_bridge="lxcbr0" -plage_ip="10.1.44" -main_iface=$(ip route | grep default | awk '{print $5;}') +client_lxc_bridge="lxcbr0" +client_lxc_plage_ip="10.1.44" +client_lxc_main_iface=$(ip route | grep default | awk '{print $5;}') #================================================= # CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS @@ -59,9 +59,9 @@ ynh_app_setting_set --app=$app --key=bootstrap_expect --value=$bootstrap_expect ynh_app_setting_set --app=$app --key=retry_join --value=$retry_join ynh_app_setting_set --app=$app --key=server_ip --value=$server_ip ynh_app_setting_set --app=$app --key=driver_lxc --value=$driver_lxc -ynh_app_setting_set --app=$app --key=lxc_bridge --value=$lxc_bridge -ynh_app_setting_set --app=$app --key=plage_ip --value=$plage_ip -ynh_app_setting_set --app=$app --key=main_iface --value=$main_iface +ynh_app_setting_set --app=$app --key=client_lxc_bridge --value=$client_lxc_bridge +ynh_app_setting_set --app=$app --key=client_lxc_plage_ip --value=$client_lxc_plage_ip +ynh_app_setting_set --app=$app --key=client_lxc_main_iface --value=$client_lxc_main_iface #================================================= # STANDARD MODIFICATIONS diff --git a/scripts/remove b/scripts/remove index 1f58367..0a4afe1 100755 --- a/scripts/remove +++ b/scripts/remove @@ -84,7 +84,7 @@ then if [ $driver_lxc -eq 1 ] then - lxc_bridge=$(ynh_app_setting_get --app=$app --key=lxc_bridge) + client_lxc_bridge=$(ynh_app_setting_get --app=$app --key=client_lxc_bridge) ynh_systemd_action --service_name=lxc-net --action="stop" systemctl disable lxc-net --quiet diff --git a/scripts/restore b/scripts/restore index 98b03d0..7ecc196 100644 --- a/scripts/restore +++ b/scripts/restore @@ -119,10 +119,10 @@ if [ "$node_type" == "client" ] then if [ $driver_lxc -eq 1 ] then - lxc_bridge=$(ynh_app_setting_get --app=$app --key=lxc_bridge) - plage_ip=$(ynh_app_setting_get --app=$app --key=plage_ip) - main_iface=$(ip route | grep default | awk '{print $5;}') - ynh_app_setting_set --app=$app --key=main_iface --value=$main_iface + client_lxc_bridge=$(ynh_app_setting_get --app=$app --key=client_lxc_bridge) + client_lxc_plage_ip=$(ynh_app_setting_get --app=$app --key=client_lxc_plage_ip) + client_lxc_main_iface=$(ip route | grep default | awk '{print $5;}') + ynh_app_setting_set --app=$app --key=client_lxc_main_iface --value=$client_lxc_main_iface ynh_add_config --template="../conf/dnsmasq-lxd" --destination="/etc/dnsmasq.d/lxd" systemctl restart dnsmasq From 556f154522d495e9cbe65cc37c94c79df17cb571 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sat, 23 Jul 2022 17:10:52 +0200 Subject: [PATCH 7/7] better dependencies management --- scripts/_common.sh | 3 ++- scripts/install | 7 ++++--- scripts/restore | 7 ++++--- scripts/upgrade | 7 ++++--- 4 files changed, 14 insertions(+), 10 deletions(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index 8a15aaa..e8fd2a4 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -5,7 +5,8 @@ #================================================= # dependencies used by the app -pkg_dependencies="nomad" +pkg_dependencies="" +extra_pkg_dependencies="nomad" server_pkg_dependencies="" diff --git a/scripts/install b/scripts/install index 27645a0..e071819 100644 --- a/scripts/install +++ b/scripts/install @@ -100,7 +100,7 @@ ynh_script_progression --message="Installing dependencies..." if [ "$node_type" == "server" ] then - ynh_install_app_dependencies $server_pkg_dependencies + pkg_dependencies="$pkg_dependencies $server_pkg_dependencies" fi if [ "$node_type" == "client" ] @@ -110,9 +110,10 @@ then client_pkg_dependencies="$client_pkg_dependencies $client_lxc_pkg_dependencies" ynh_exec_warn_less ynh_install_go --go_version=$go_version fi - ynh_install_app_dependencies $client_pkg_dependencies + pkg_dependencies="$pkg_dependencies $client_pkg_dependencies" fi -ynh_install_extra_app_dependencies --repo="deb https://apt.releases.hashicorp.com $(lsb_release -cs) main" --package="$pkg_dependencies" --key="https://apt.releases.hashicorp.com/gpg" +ynh_install_app_dependencies $pkg_dependencies +ynh_install_extra_app_dependencies --repo="deb https://apt.releases.hashicorp.com $(lsb_release -cs) main" --package="$extra_pkg_dependencies" --key="https://apt.releases.hashicorp.com/gpg" #================================================= # CREATE DEDICATED USER diff --git a/scripts/restore b/scripts/restore index 7ecc196..cdc1c18 100644 --- a/scripts/restore +++ b/scripts/restore @@ -74,7 +74,7 @@ ynh_script_progression --message="Reinstalling dependencies..." if [ "$node_type" == "server" ] then - ynh_install_app_dependencies $server_pkg_dependencies + pkg_dependencies="$pkg_dependencies $server_pkg_dependencies" fi if [ "$node_type" == "client" ] @@ -83,9 +83,10 @@ then then client_pkg_dependencies="$client_pkg_dependencies $client_lxc_pkg_dependencies" fi - ynh_install_app_dependencies $client_pkg_dependencies + pkg_dependencies="$pkg_dependencies $client_pkg_dependencies" fi -ynh_install_extra_app_dependencies --repo="deb https://apt.releases.hashicorp.com $(lsb_release -cs) main" --package="$pkg_dependencies" --key="https://apt.releases.hashicorp.com/gpg" +ynh_install_app_dependencies $pkg_dependencies +ynh_install_extra_app_dependencies --repo="deb https://apt.releases.hashicorp.com $(lsb_release -cs) main" --package="$extra_pkg_dependencies" --key="https://apt.releases.hashicorp.com/gpg" #================================================= # RESTORE THE NGINX CONFIGURATION diff --git a/scripts/upgrade b/scripts/upgrade index c48777c..853cc02 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -88,7 +88,7 @@ ynh_script_progression --message="Upgrading dependencies..." if [ "$node_type" == "server" ] then - ynh_install_app_dependencies $server_pkg_dependencies + pkg_dependencies="$pkg_dependencies $server_pkg_dependencies" fi if [ "$node_type" == "client" ] @@ -98,9 +98,10 @@ then client_pkg_dependencies="$client_pkg_dependencies $client_lxc_pkg_dependencies" ynh_exec_warn_less ynh_install_go --go_version=$go_version fi - ynh_install_app_dependencies $client_pkg_dependencies + pkg_dependencies="$pkg_dependencies $client_pkg_dependencies" fi -ynh_install_extra_app_dependencies --repo="deb https://apt.releases.hashicorp.com $(lsb_release -cs) main" --package="$pkg_dependencies" --key="https://apt.releases.hashicorp.com/gpg" +ynh_install_app_dependencies $pkg_dependencies +ynh_install_extra_app_dependencies --repo="deb https://apt.releases.hashicorp.com $(lsb_release -cs) main" --package="$extra_pkg_dependencies" --key="https://apt.releases.hashicorp.com/gpg" #================================================= # NGINX CONFIGURATION