mirror of
https://github.com/YunoHost-Apps/nomad_ynh.git
synced 2024-09-03 19:55:53 +02:00
commit
1c7f266b97
11 changed files with 200 additions and 88 deletions
|
@ -3,7 +3,10 @@
|
||||||
domain="domain.tld"
|
domain="domain.tld"
|
||||||
is_public=1
|
is_public=1
|
||||||
node_type="client"
|
node_type="client"
|
||||||
|
bootstrap_expect="1"
|
||||||
|
retry_join="192.168.1.100"
|
||||||
server_ip="192.168.1.100"
|
server_ip="192.168.1.100"
|
||||||
|
driver_lxc=1
|
||||||
; Checks
|
; Checks
|
||||||
pkg_linter=1
|
pkg_linter=1
|
||||||
setup_sub_dir=0
|
setup_sub_dir=0
|
||||||
|
@ -22,7 +25,10 @@
|
||||||
domain="domain.tld"
|
domain="domain.tld"
|
||||||
is_public=1
|
is_public=1
|
||||||
node_type="server"
|
node_type="server"
|
||||||
|
bootstrap_expect="1"
|
||||||
|
retry_join="192.168.1.100"
|
||||||
server_ip="none..."
|
server_ip="none..."
|
||||||
|
driver_lxc=1
|
||||||
; Checks
|
; Checks
|
||||||
pkg_linter=1
|
pkg_linter=1
|
||||||
setup_sub_dir=0
|
setup_sub_dir=0
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
lxc.net.0.type = veth
|
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.flags = up
|
||||||
lxc.net.0.hwaddr = 00:16:3e:xx:xx:xx
|
lxc.net.0.hwaddr = 00:16:3e:xx:xx:xx
|
||||||
lxc.apparmor.profile = generated
|
lxc.apparmor.profile = generated
|
||||||
|
|
|
@ -1,2 +1,2 @@
|
||||||
bind-interfaces
|
bind-interfaces
|
||||||
except-interface=__LXC_BRIDGE__
|
except-interface=__CLIENT_LXC_BRIDGE__
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
USE_LXC_BRIDGE="true"
|
USE_LXC_BRIDGE="true"
|
||||||
LXC_BRIDGE="__LXC_BRIDGE__"
|
LXC_BRIDGE="__CLIENT_LXC_BRIDGE__"
|
||||||
LXC_ADDR="__PLAGE_IP__.1"
|
LXC_ADDR="__CLIENT_LXC_PLAGE_IP__.1"
|
||||||
LXC_NETMASK="255.255.255.0"
|
LXC_NETMASK="255.255.255.0"
|
||||||
LXC_NETWORK="__PLAGE_IP__.0/24"
|
LXC_NETWORK="__CLIENT_LXC_PLAGE_IP__.0/24"
|
||||||
LXC_DHCP_RANGE="__PLAGE_IP__.2,__PLAGE_IP__.254"
|
LXC_DHCP_RANGE="__CLIENT_LXC_PLAGE_IP__.2,__CLIENT_LXC_PLAGE_IP__.254"
|
||||||
LXC_DHCP_MAX="253"
|
LXC_DHCP_MAX="253"
|
||||||
LXC_DHCP_CONFILE=""
|
LXC_DHCP_CONFILE=""
|
||||||
LXC_DOMAIN=""
|
LXC_DOMAIN=""
|
||||||
|
|
|
@ -8,7 +8,7 @@ server {
|
||||||
# This is an integer representing the number of server nodes to wait for before bootstrapping. It is most
|
# 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
|
# 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.
|
# 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
|
# 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.
|
# directory lives inside of the data_dir in the "server" sub-path.
|
||||||
|
@ -38,7 +38,7 @@ server {
|
||||||
|
|
||||||
# Similar to start_join but allows retrying a join if the first attempt fails. This is useful for cases
|
# 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.
|
# 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.
|
# The time to wait between join attempts. Defaults to 30s.
|
||||||
retry_interval = "30s"
|
retry_interval = "30s"
|
||||||
|
|
|
@ -45,6 +45,27 @@
|
||||||
"choices": ["server", "client"],
|
"choices": ["server", "client"],
|
||||||
"default": "server"
|
"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": "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",
|
"name": "server_ip",
|
||||||
"type": "string",
|
"type": "string",
|
||||||
|
@ -53,6 +74,26 @@
|
||||||
},
|
},
|
||||||
"example": "192.168.1.100",
|
"example": "192.168.1.100",
|
||||||
"optional": true
|
"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."
|
||||||
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,9 +5,13 @@
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
# dependencies used by the app
|
# dependencies used by the app
|
||||||
pkg_dependencies="nomad"
|
pkg_dependencies=""
|
||||||
|
extra_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
|
go_version=1.15
|
||||||
|
|
||||||
|
|
86
scripts/install
Executable file → Normal file
86
scripts/install
Executable file → Normal file
|
@ -28,13 +28,16 @@ domain=$YNH_APP_ARG_DOMAIN
|
||||||
path_url="/"
|
path_url="/"
|
||||||
is_public=$YNH_APP_ARG_IS_PUBLIC
|
is_public=$YNH_APP_ARG_IS_PUBLIC
|
||||||
node_type=$YNH_APP_ARG_NODE_TYPE
|
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
|
server_ip=$YNH_APP_ARG_SERVER_IP
|
||||||
|
driver_lxc=$YNH_APP_ARG_DRIVER_LXC
|
||||||
|
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
|
|
||||||
lxc_bridge="lxcbr0"
|
client_lxc_bridge="lxcbr0"
|
||||||
plage_ip="10.1.44"
|
client_lxc_plage_ip="10.1.44"
|
||||||
main_iface=$(ip route | grep default | awk '{print $5;}')
|
client_lxc_main_iface=$(ip route | grep default | awk '{print $5;}')
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
|
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
|
||||||
|
@ -52,10 +55,13 @@ ynh_script_progression --message="Storing installation settings..."
|
||||||
ynh_app_setting_set --app=$app --key=domain --value=$domain
|
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=path --value=$path_url
|
||||||
ynh_app_setting_set --app=$app --key=node_type --value=$node_type
|
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=server_ip --value=$server_ip
|
||||||
ynh_app_setting_set --app=$app --key=lxc_bridge --value=$lxc_bridge
|
ynh_app_setting_set --app=$app --key=driver_lxc --value=$driver_lxc
|
||||||
ynh_app_setting_set --app=$app --key=plage_ip --value=$plage_ip
|
ynh_app_setting_set --app=$app --key=client_lxc_bridge --value=$client_lxc_bridge
|
||||||
ynh_app_setting_set --app=$app --key=main_iface --value=$main_iface
|
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
|
# STANDARD MODIFICATIONS
|
||||||
|
@ -92,12 +98,22 @@ fi
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Installing dependencies..."
|
ynh_script_progression --message="Installing dependencies..."
|
||||||
|
|
||||||
|
if [ "$node_type" == "server" ]
|
||||||
|
then
|
||||||
|
pkg_dependencies="$pkg_dependencies $server_pkg_dependencies"
|
||||||
|
fi
|
||||||
|
|
||||||
if [ "$node_type" == "client" ]
|
if [ "$node_type" == "client" ]
|
||||||
then
|
then
|
||||||
ynh_install_app_dependencies $client_pkg_dependencies
|
if [ $driver_lxc -eq 1 ]
|
||||||
ynh_exec_warn_less ynh_install_go --go_version=$go_version
|
then
|
||||||
|
client_pkg_dependencies="$client_pkg_dependencies $client_lxc_pkg_dependencies"
|
||||||
|
ynh_exec_warn_less ynh_install_go --go_version=$go_version
|
||||||
|
fi
|
||||||
|
pkg_dependencies="$pkg_dependencies $client_pkg_dependencies"
|
||||||
fi
|
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
|
# CREATE DEDICATED USER
|
||||||
|
@ -133,27 +149,30 @@ chmod -R o-rwx "$datadir"
|
||||||
chown -R $app:$app "$datadir"
|
chown -R $app:$app "$datadir"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# BUILD LXC DRIVER
|
# BUILD DRIVERS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
if [ "$node_type" == "client" ]
|
if [ "$node_type" == "client" ]
|
||||||
then
|
then
|
||||||
ynh_script_progression --message="Building LXC driver..."
|
if [ $driver_lxc -eq 1 ]
|
||||||
|
then
|
||||||
|
ynh_script_progression --message="Building LXC driver..."
|
||||||
|
|
||||||
tempdir="$(mktemp -d)"
|
tempdir="$(mktemp -d)"
|
||||||
ynh_setup_source --dest_dir="$tempdir" --source_id="driver-lxc"
|
ynh_setup_source --dest_dir="$tempdir" --source_id="driver-lxc"
|
||||||
|
|
||||||
pushd $tempdir
|
pushd $tempdir
|
||||||
final_path=$tempdir
|
final_path=$tempdir
|
||||||
ynh_use_go
|
ynh_use_go
|
||||||
export GOPATH="$tempdir/go"
|
export GOPATH="$tempdir/go"
|
||||||
export GOCACHE="$tempdir/.cache"
|
export GOCACHE="$tempdir/.cache"
|
||||||
ynh_exec_warn_less $ynh_go build
|
ynh_exec_warn_less $ynh_go build
|
||||||
popd
|
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
|
fi
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -186,19 +205,22 @@ then
|
||||||
chmod 400 "$config_path/client.hcl"
|
chmod 400 "$config_path/client.hcl"
|
||||||
chown $app:$app "$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"
|
if [ $driver_lxc -eq 1 ]
|
||||||
chmod 400 "$config_path/driver-lxc.hcl"
|
then
|
||||||
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"
|
ynh_add_config --template="../conf/dnsmasq-lxd" --destination="/etc/dnsmasq.d/lxd"
|
||||||
systemctl restart dnsmasq
|
systemctl restart dnsmasq
|
||||||
|
|
||||||
if [ ! ${PACKAGE_CHECK_EXEC:-0} -eq 1 ]; then
|
if [ ! ${PACKAGE_CHECK_EXEC:-0} -eq 1 ]; then
|
||||||
ynh_add_config --template="../conf/lxc-net" --destination="/etc/default/lxc-net"
|
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
|
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
|
fi
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
|
@ -21,6 +21,7 @@ domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||||
config_path=$(ynh_app_setting_get --app=$app --key=config_path)
|
config_path=$(ynh_app_setting_get --app=$app --key=config_path)
|
||||||
datadir=$(ynh_app_setting_get --app=$app --key=datadir)
|
datadir=$(ynh_app_setting_get --app=$app --key=datadir)
|
||||||
node_type=$(ynh_app_setting_get --app=$app --key=node_type)
|
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)
|
rpc_port=$(ynh_app_setting_get --app=$app --key=rpc_port)
|
||||||
serf_port=$(ynh_app_setting_get --app=$app --key=serf_port)
|
serf_port=$(ynh_app_setting_get --app=$app --key=serf_port)
|
||||||
|
|
||||||
|
@ -81,14 +82,17 @@ fi
|
||||||
if [ "$node_type" == "client" ]
|
if [ "$node_type" == "client" ]
|
||||||
then
|
then
|
||||||
|
|
||||||
lxc_bridge=$(ynh_app_setting_get --app=$app --key=lxc_bridge)
|
if [ $driver_lxc -eq 1 ]
|
||||||
|
then
|
||||||
|
client_lxc_bridge=$(ynh_app_setting_get --app=$app --key=client_lxc_bridge)
|
||||||
|
|
||||||
ynh_systemd_action --service_name=lxc-net --action="stop"
|
ynh_systemd_action --service_name=lxc-net --action="stop"
|
||||||
systemctl disable lxc-net --quiet
|
systemctl disable lxc-net --quiet
|
||||||
ynh_secure_remove --file="/etc/default/lxc-net"
|
ynh_secure_remove --file="/etc/default/lxc-net"
|
||||||
ynh_secure_remove --file="/etc/lxc/default.conf"
|
ynh_secure_remove --file="/etc/lxc/default.conf"
|
||||||
ynh_secure_remove --file="/etc/dnsmasq.d/lxd"
|
ynh_secure_remove --file="/etc/dnsmasq.d/lxd"
|
||||||
systemctl restart dnsmasq
|
systemctl restart dnsmasq
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -100,7 +104,10 @@ ynh_script_progression --message="Removing dependencies..."
|
||||||
ynh_remove_app_dependencies
|
ynh_remove_app_dependencies
|
||||||
if [ "$node_type" == "client" ]
|
if [ "$node_type" == "client" ]
|
||||||
then
|
then
|
||||||
ynh_remove_go
|
if [ $driver_lxc -eq 1 ]
|
||||||
|
then
|
||||||
|
ynh_remove_go
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
43
scripts/restore
Executable file → Normal file
43
scripts/restore
Executable file → Normal file
|
@ -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)
|
config_path=$(ynh_app_setting_get --app=$app --key=config_path)
|
||||||
datadir=$(ynh_app_setting_get --app=$app --key=datadir)
|
datadir=$(ynh_app_setting_get --app=$app --key=datadir)
|
||||||
node_type=$(ynh_app_setting_get --app=$app --key=node_type)
|
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)
|
http_port=$(ynh_app_setting_get --app=$app --key=http_port)
|
||||||
rpc_port=$(ynh_app_setting_get --app=$app --key=rpc_port)
|
rpc_port=$(ynh_app_setting_get --app=$app --key=rpc_port)
|
||||||
serf_port=$(ynh_app_setting_get --app=$app --key=serf_port)
|
serf_port=$(ynh_app_setting_get --app=$app --key=serf_port)
|
||||||
|
@ -71,11 +72,21 @@ chown -R $app:$app "$datadir"
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Reinstalling dependencies..."
|
ynh_script_progression --message="Reinstalling dependencies..."
|
||||||
|
|
||||||
|
if [ "$node_type" == "server" ]
|
||||||
|
then
|
||||||
|
pkg_dependencies="$pkg_dependencies $server_pkg_dependencies"
|
||||||
|
fi
|
||||||
|
|
||||||
if [ "$node_type" == "client" ]
|
if [ "$node_type" == "client" ]
|
||||||
then
|
then
|
||||||
ynh_install_app_dependencies $client_pkg_dependencies
|
if [ $driver_lxc -eq 1 ]
|
||||||
|
then
|
||||||
|
client_pkg_dependencies="$client_pkg_dependencies $client_lxc_pkg_dependencies"
|
||||||
|
fi
|
||||||
|
pkg_dependencies="$pkg_dependencies $client_pkg_dependencies"
|
||||||
fi
|
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
|
# RESTORE THE NGINX CONFIGURATION
|
||||||
|
@ -107,22 +118,24 @@ fi
|
||||||
|
|
||||||
if [ "$node_type" == "client" ]
|
if [ "$node_type" == "client" ]
|
||||||
then
|
then
|
||||||
|
if [ $driver_lxc -eq 1 ]
|
||||||
|
then
|
||||||
|
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
|
||||||
|
|
||||||
lxc_bridge=$(ynh_app_setting_get --app=$app --key=lxc_bridge)
|
ynh_add_config --template="../conf/dnsmasq-lxd" --destination="/etc/dnsmasq.d/lxd"
|
||||||
plage_ip=$(ynh_app_setting_get --app=$app --key=plage_ip)
|
systemctl restart dnsmasq
|
||||||
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"
|
if [ ! ${PACKAGE_CHECK_EXEC:-0} -eq 1 ]; then
|
||||||
systemctl restart dnsmasq
|
ynh_add_config --template="../conf/lxc-net" --destination="/etc/default/lxc-net"
|
||||||
|
fi
|
||||||
if [ ! ${PACKAGE_CHECK_EXEC:-0} -eq 1 ]; then
|
ynh_secure_remove --file="/etc/lxc/default.conf"
|
||||||
ynh_add_config --template="../conf/lxc-net" --destination="/etc/default/lxc-net"
|
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
|
fi
|
||||||
ynh_secure_remove --file="/etc/lxc/default.conf"
|
|
||||||
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
|
fi
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
|
@ -22,7 +22,10 @@ path_url=$(ynh_app_setting_get --app=$app --key=path)
|
||||||
config_path=$(ynh_app_setting_get --app=$app --key=config_path)
|
config_path=$(ynh_app_setting_get --app=$app --key=config_path)
|
||||||
datadir=$(ynh_app_setting_get --app=$app --key=datadir)
|
datadir=$(ynh_app_setting_get --app=$app --key=datadir)
|
||||||
node_type=$(ynh_app_setting_get --app=$app --key=node_type)
|
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)
|
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)
|
http_port=$(ynh_app_setting_get --app=$app --key=http_port)
|
||||||
rpc_port=$(ynh_app_setting_get --app=$app --key=rpc_port)
|
rpc_port=$(ynh_app_setting_get --app=$app --key=rpc_port)
|
||||||
serf_port=$(ynh_app_setting_get --app=$app --key=serf_port)
|
serf_port=$(ynh_app_setting_get --app=$app --key=serf_port)
|
||||||
|
@ -83,12 +86,22 @@ ynh_system_user_create --username=$app
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Upgrading dependencies..."
|
ynh_script_progression --message="Upgrading dependencies..."
|
||||||
|
|
||||||
|
if [ "$node_type" == "server" ]
|
||||||
|
then
|
||||||
|
pkg_dependencies="$pkg_dependencies $server_pkg_dependencies"
|
||||||
|
fi
|
||||||
|
|
||||||
if [ "$node_type" == "client" ]
|
if [ "$node_type" == "client" ]
|
||||||
then
|
then
|
||||||
ynh_install_app_dependencies $client_pkg_dependencies
|
if [ $driver_lxc -eq 1 ]
|
||||||
ynh_exec_warn_less ynh_install_go --go_version=$go_version
|
then
|
||||||
|
client_pkg_dependencies="$client_pkg_dependencies $client_lxc_pkg_dependencies"
|
||||||
|
ynh_exec_warn_less ynh_install_go --go_version=$go_version
|
||||||
|
fi
|
||||||
|
pkg_dependencies="$pkg_dependencies $client_pkg_dependencies"
|
||||||
fi
|
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
|
# NGINX CONFIGURATION
|
||||||
|
@ -101,27 +114,30 @@ ynh_add_nginx_config
|
||||||
#=================================================
|
#=================================================
|
||||||
# SPECIFIC UPGRADE
|
# SPECIFIC UPGRADE
|
||||||
#=================================================
|
#=================================================
|
||||||
# BUILD LXC DRIVER
|
# BUILD DRIVERS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
if [ "$node_type" == "client" ]
|
if [ "$node_type" == "client" ]
|
||||||
then
|
then
|
||||||
ynh_script_progression --message="Building LXC driver..."
|
if [ $driver_lxc -eq 1 ]
|
||||||
|
then
|
||||||
|
ynh_script_progression --message="Building LXC driver..."
|
||||||
|
|
||||||
tempdir="$(mktemp -d)"
|
tempdir="$(mktemp -d)"
|
||||||
ynh_setup_source --dest_dir="$tempdir" --source_id="driver-lxc"
|
ynh_setup_source --dest_dir="$tempdir" --source_id="driver-lxc"
|
||||||
|
|
||||||
pushd $tempdir
|
pushd $tempdir
|
||||||
final_path=$tempdir
|
final_path=$tempdir
|
||||||
ynh_use_go
|
ynh_use_go
|
||||||
export GOPATH="$tempdir/go"
|
export GOPATH="$tempdir/go"
|
||||||
export GOCACHE="$tempdir/.cache"
|
export GOCACHE="$tempdir/.cache"
|
||||||
ynh_exec_warn_less $ynh_go build
|
ynh_exec_warn_less $ynh_go build
|
||||||
popd
|
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
|
fi
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -151,9 +167,12 @@ then
|
||||||
chmod 400 "$config_path/client.hcl"
|
chmod 400 "$config_path/client.hcl"
|
||||||
chown $app:$app "$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"
|
if [ $driver_lxc -eq 1 ]
|
||||||
chmod 400 "$config_path/driver-lxc.hcl"
|
then
|
||||||
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"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
Loading…
Reference in a new issue