start.sh 687 B

12345678910111213141516171819202122232425
  1. #!/bin/bash
  2. BASE_DIR="/opt/vpnserver"
  3. # config file check
  4. [ -f $BASE_DIR/vpn_server.config ] || { echo "Config is not a file! Check your docker settings."; exit 1; }
  5. # first start
  6. if [ -s $BASE_DIR/vpn_server.config ]
  7. then
  8. echo "Config exists."
  9. else
  10. echo "Config not exists, creating a basic configuration..."
  11. $BASE_DIR/vpnserver start
  12. sleep 2
  13. $BASE_DIR/vpnserver stop
  14. # basic config for remote management
  15. $BASE_DIR/vpncmd RemoteEnable
  16. fi
  17. # start vpn service
  18. $BASE_DIR/vpnserver start
  19. # something daemon like stuff
  20. [ $( ls -1 $BASE_DIR/server_log/* | wc -l ) -gt 0 ] && { tail -f $BASE_DIR/server_log/*; } || { echo "sorry, log file not found"; tail -f /dev/null; }