Browse Source

some fixes and updates for working version

crocandr 6 years ago
parent
commit
176fd6dade
5 changed files with 31 additions and 30 deletions
  1. 1 1
      Dockerfile
  2. 10 0
      README.md
  3. 0 0
      config/vpn_server.config
  4. 7 3
      docker-compose.yml
  5. 13 26
      files/start.sh

+ 1 - 1
Dockerfile

@@ -6,7 +6,7 @@ RUN apt-get update && apt-get install -y curl tar gzip grep make gcc cpp
 RUN curl -L -o /opt/softether.tar.gz $DOWNLOAD_URL && tar xzfp /opt/softether.tar.gz -C /opt 
 RUN curl -L -o /opt/softether.tar.gz $DOWNLOAD_URL && tar xzfp /opt/softether.tar.gz -C /opt 
 RUN cd /opt/vpnserver && make i_read_and_agree_the_license_agreement 
 RUN cd /opt/vpnserver && make i_read_and_agree_the_license_agreement 
 
 
-COPY files/start.sh /opt/start.sh
+COPY files/* /opt/
 RUN chmod 755 /opt/*.sh
 RUN chmod 755 /opt/*.sh
 
 
 #ENTRYPOINT /bin/bash
 #ENTRYPOINT /bin/bash

+ 10 - 0
README.md

@@ -8,6 +8,15 @@ My basic SoftEther VPN Server container.
 
 
 The recommended way is docker-compose.
 The recommended way is docker-compose.
 
 
+VERY IMPORTANT!: Create an empty config file with world-wide write permission under the config folder before start the server:
+```
+mkdir config
+touch config/vpn_server.config
+chmod 777 config/vpn_server.config
+```
+
+Start the container:
+
 ```
 ```
 docker-compose up -d
 docker-compose up -d
 ```
 ```
@@ -19,3 +28,4 @@ docker-compose up -d
   
   
 Notice:
 Notice:
 sometimes the default 443 port is used by another service, so use another available port like 5555, 8888...
 sometimes the default 443 port is used by another service, so use another available port like 5555, 8888...
+

+ 0 - 0
config/vpn_server.config


+ 7 - 3
docker-compose.yml

@@ -4,9 +4,13 @@ services:
   softether:
   softether:
     image: croc/softether
     image: croc/softether
     volumes:
     volumes:
-      - './config:/config'
-      - './log:/log'
+      - './logs/packet_log:/opt/vpnserver/packet_log'
+      - './logs/security_log:/opt/vpnserver/security_log'
+      - './logs/server_log:/opt/vpnserver/server_log'
+      - './config/backup.vpn_server.config:/opt/vpnserver/backup.vpn_server.config'
+      - './config/chain_certs:/opt/vpnserver/chain_certs'
+      - './config/vpn_server.config:/opt/vpnserver/vpn_server.config'
       - '/etc/localtime:/etc/localtime:ro'
       - '/etc/localtime:/etc/localtime:ro'
     privileged: true
     privileged: true
     network_mode: host
     network_mode: host
-#    restart: always
+    restart: unless-stopped 

+ 13 - 26
files/start.sh

@@ -1,35 +1,22 @@
 #!/bin/bash
 #!/bin/bash
 
 
 BASE_DIR="/opt/vpnserver"
 BASE_DIR="/opt/vpnserver"
-CONFIG_DIR="/config"
-LOG_DIR="/log"
 
 
-[ -z $VERBOSE ] && { VERBOSE="yes"; }
-
-# prestart vpn server
-$BASE_DIR/vpnserver start
-sleep 1
-$BASE_DIR/vpnserver stop
-
-# config
-[ -d $CONFIG_DIR ] || { mkdir -p $CONFIG_DIR; }
-echo "Preconfiguring config files..."
-[ -d $BASE_DIR/backup.vpn_server.config ] && { mv $BASE_DIR/backup.vpn_server.config $CONFIG_DIR && ln -sf $CONFIG_DIR/backup.vpn_server.config $BASE_DIR; }
-[ -d $BASE_DIR/chain_certs ] && { mv $BASE_DIR/chain_certs $CONFIG_DIR && ln -sf $CONFIG_DIR/chain_certs $BASE_DIR; }
-[ -f $BASE_DIR/vpn_server.config ] && { mv $BASE_DIR/vpn_server.config $CONFIG_DIR && ln -sf $CONFIG_DIR/vpn_server.config $BASE_DIR; }
-
-# log
-[ -d $LOG_DIR ] || { mkdir -p $LOG_DIR; }
-for logf in $BASE_DIR/*_log
-do
-  [ -d $logf ] && { mv $logf $LOG_DIR && ln -sf $LOG_DIR/$( basename $logf ) $BASE_DIR; }
-done
-
-# basic config
-$BASE_DIR/vpncmd RemoteEnable
+# first start 
+if [ -s $BASE_DIR/vpn_server.config ]
+then
+  echo "Config exists."
+else
+  echo "Config not exists, creating a basic configuration..."
+  $BASE_DIR/vpnserver start
+  sleep 2 
+  $BASE_DIR/vpnserver stop
+  # basic config for remote management
+  $BASE_DIR/vpncmd RemoteEnable
+fi
 
 
 # start vpn service
 # start vpn service
 $BASE_DIR/vpnserver start
 $BASE_DIR/vpnserver start
 
 
 # something daemon like stuff
 # something daemon like stuff
-[ $VERBOSE == "no" ] && { /bin/bash; } || { tail -f $LOG_DIR/server_log/*.log; }
+tail -f $BASE_DIR/server_log/*