#!/bin/bash # fail fast set -e # Symbolic file LINK_CONF="config.json" if [ ! -h "$LINK_CONF" ] then echo "'$LINK_CONF' is not a symbolic file or not exist" exit 1 fi # Find target config file CURR_CONF=$(readlink $LINK_CONF) echo "Current config file: $CURR_CONF" # This filename FILE=$(basename $0) # Other config file CONFS=$(ls -1 -I $CURR_CONF -I $LINK_CONF -I $FILE) NUM_OF_CONF=${#CONFS[*]} echo echo "Available options:" PS3="Select new config: " select conf in $CONFS do if [ "$REPLY" -lt 1 -o "$REPLY" -gt "$NUM_OF_CONF" ] then echo echo "Invalid option $REPLY" else echo echo "Selected $conf, now link new config to selection" sudo ln -f -s $conf $LINK_CONF echo "Restart service..." sudo systemctl restart v2ray break fi done exit