zerotier: add option to copy config
Signed-off-by: Moritz Warning <moritzwarning@web.de>
This commit is contained in:
parent
1f91016ac3
commit
078bd4189c
2 changed files with 11 additions and 4 deletions
|
@ -4,6 +4,8 @@ config zerotier sample_config
|
||||||
|
|
||||||
# persistent configuration folder (for ZT controller mode)
|
# persistent configuration folder (for ZT controller mode)
|
||||||
#option config_path '/etc/zerotier'
|
#option config_path '/etc/zerotier'
|
||||||
|
# copy <config_path> to RAM to prevent writing to flash (for ZT controller mode)
|
||||||
|
#option copy_config_path '1'
|
||||||
|
|
||||||
#option port '9993'
|
#option port '9993'
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@ section_enabled() {
|
||||||
|
|
||||||
start_instance() {
|
start_instance() {
|
||||||
local cfg="$1"
|
local cfg="$1"
|
||||||
local port secret config_path local_conf path
|
local port secret config_path local_conf copy_config_path path
|
||||||
local args=""
|
local args=""
|
||||||
|
|
||||||
if ! section_enabled "$cfg"; then
|
if ! section_enabled "$cfg"; then
|
||||||
|
@ -26,24 +26,29 @@ start_instance() {
|
||||||
config_get port $cfg 'port'
|
config_get port $cfg 'port'
|
||||||
config_get secret $cfg 'secret'
|
config_get secret $cfg 'secret'
|
||||||
config_get local_conf $cfg 'local_conf'
|
config_get local_conf $cfg 'local_conf'
|
||||||
|
config_get_bool copy_config_path $cfg 'copy_config_path' 0
|
||||||
|
|
||||||
path=${CONFIG_PATH}_$cfg
|
path=${CONFIG_PATH}_$cfg
|
||||||
|
|
||||||
# Remove existing link or folder
|
# Remove existing link or folder
|
||||||
rm -rf $path
|
rm -rf $path
|
||||||
|
|
||||||
# Create link from CONFIG_PATH to config_path
|
# Create link or copy files from CONFIG_PATH to config_path
|
||||||
if [ -n "$config_path" -a "$config_path" != "$path" ]; then
|
if [ -n "$config_path" -a "$config_path" != "$path" ]; then
|
||||||
if [ ! -d "$config_path" ]; then
|
if [ ! -d "$config_path" ]; then
|
||||||
echo "ZeroTier config_path does not exist: $config_path" 1>&2
|
echo "ZeroTier config_path does not exist: $config_path" 1>&2
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# ensure that the symlink target exists
|
# ensure that the target exists
|
||||||
mkdir -p $(dirname $path)
|
mkdir -p $(dirname $path)
|
||||||
|
|
||||||
|
if [ "$copy_config_path" = "1" ]; then
|
||||||
|
cp -r $config_path $path
|
||||||
|
else
|
||||||
ln -s $config_path $path
|
ln -s $config_path $path
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
mkdir -p $path/networks.d
|
mkdir -p $path/networks.d
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue