Add management scripts

This commit is contained in:
KAAAsS 2021-04-15 21:46:05 +08:00
parent 273ad82fb8
commit 3fb07c0c2d
Signed by: KAAAsS
GPG Key ID: D56625F3E671882F
3 changed files with 89 additions and 0 deletions

26
script/create.sh Executable file
View File

@ -0,0 +1,26 @@
#!/bin/bash
set -e
BIRD_CONF_DIR=$(dirname "$0")/../
# Root check
if [[ $(id -u) -ne 0 ]]; then
echo "Run this script with root!" >&2
exit 1
fi
# Check param
if [[ $# -ne 1 ]]; then
echo "Usage: $0 [config name]" >&2
echo "Create config from example" >&2
exit 1
fi
CONF_NAME=$1
# Create conf folder
mkdir -p $BIRD_CONF_DIR/concrete
# Copy example config
cp -r $BIRD_CONF_DIR/example $BIRD_CONF_DIR/concrete/$CONF_NAME
echo "Config $CONF_NAME created"

30
script/delete.sh Executable file
View File

@ -0,0 +1,30 @@
#!/bin/bash
set -e
BIRD_CONF_DIR=$(dirname "$0")/../
# Root check
if [[ $(id -u) -ne 0 ]]; then
echo "Run this script with root!" >&2
exit 1
fi
# Check param
if [[ $# -ne 1 ]]; then
echo "Usage: $0 [config name]" >&2
echo "Delete existing config"
exit 1
fi
CONF_NAME=$1
# Create conf folder
mkdir -p $BIRD_CONF_DIR/concrete
# Delete config
if [[ -d $BIRD_CONF_DIR/concrete/$CONF_NAME ]]; then
rm -rf $BIRD_CONF_DIR/concrete/$CONF_NAME
echo "Config $CONF_NAME deleted"
else
echo "Config $CONF_NAME not existed" >&2
exit 2
fi

33
script/enable.sh Executable file
View File

@ -0,0 +1,33 @@
#!/bin/bash
set -e
BIRD_CONF_DIR=$(dirname "$0")/../
# Root check
if [[ $(id -u) -ne 0 ]]; then
echo "Run this script with root!" >&2
exit 1
fi
# Check param
if [[ $# -ne 1 ]]; then
echo "Usage: $0 [config name]" >&2
echo "Enable existing config"
exit 1
fi
CONF_NAME=$1
# Create conf folder
mkdir -p $BIRD_CONF_DIR/concrete
# Enable config
if [[ -d $BIRD_CONF_DIR/concrete/$CONF_NAME ]]; then
rm -f $BIRD_CONF_DIR/conf
ln -s $BIRD_CONF_DIR/concrete/$CONF_NAME $BIRD_CONF_DIR/conf
echo "Config $CONF_NAME enabled"
/usr/bin/birdc configure
echo "Config $CONF_NAME configured"
else
echo "Config $CONF_NAME not existed" >&2
exit 2
fi