-
Notifications
You must be signed in to change notification settings - Fork 1
/
init-env.sh
executable file
·82 lines (80 loc) · 3.03 KB
/
init-env.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#!/bin/bash
echo "init-env.sh@bash: v2.0, 20190321"
## Variables
# Write down the data required in .env file here for initiation.
ENVFILENAME=.env
ENVFILECONTENTS=(
"##"
"# GENERAL SETTINGS"
"##"
"# TIMEZONE"
"# Leave empty or comment out if it is not used."
"TZ="
"# The script will check VPN connection periodically please define the period in seconds between checks."
"# Mandatory, Default 3600"
"SLEEPTIME=3600"
"# Log level for the scripts. Can be [ SILENT, ERROR, WARN, LIFETIME, INFO, DEBUG ] (default: INFO)"
"LOG_LEVEL=INFO"
"##"
"# SOFTETHER VPN CLIENT SETTINGS"
"##"
"# VPN file relative path. Exported .vpn file name which must include the authentication parameters as well"
"# Mandatory, Default defaultconn"
"CONNNAME=defaultconn"
"# Static MAC address."
"# Leave empty or comment out if it is not used."
"MACADD="
"# Set true for internal connection to set mtu 1200 or 1500."
"# Leave empty or comment out if it is not used."
"INTCONN="
"##"
"# If your network gateway address of the VPN server is different than 1, it will override it."
"# Leave empty or comment out if it is not used."
"NETWORKGATEWAY="
"# EMBEDDED SAMBA SERVER SETTINGS"
"##"
"# Enable or disable internal Samba server."
"# Leave empty or comment out if it is not used."
"SAMBAENABLE="
"# Server WINS identification name"
"# Leave empty or comment out if it is not used."
"SRVNAME="
"# USERS: required arg: <username>;<passwd>"
"# <username> for user"
"# <password> for user"
"# [ID] for user"
"# [group] for user"
"# multiple user format: example1;password:example2;password"
"# Leave empty or comment out if it is not used."
"USERS="
"# MOUNTS: Configure a share"
"# required arg: <name>;</path>"
"# <name> is how it's called for clients"
"# <path> path to share"
"# NOTE: for the default value, just leave blank"
"# [browsable] default:'yes' or 'no'"
"# [readonly] default:'yes' or 'no'"
"# [guest] allowed default:'yes' or 'no'"
"# [users] allowed default:'all' or list of allowed users"
"# [admins] allowed default:'none' or list of admin users"
"# [writelist] list of users that can write to a RO share"
"# [comment] description of share"
"# multiple mount format: example1:'private share';/example1;no;no;no;example2:'very private share';/example2;no;no;no;example2"
"# Leave empty or comment out if it is not used."
"MOUNTS="
"# WORKGROUP NAME"
"# Leave empty or comment out if it is not used."
"WORKGROUPNAME=WORKGROUP"
)
## Script
echo "Initiating ${ENVFILENAME} file."
if [[ ! -f ${ENVFILENAME} ]] || (echo -n ".env file already initiated. You want to override? [ y/N ]: " && read -r OVERRIDE && echo ${OVERRIDE::1} | grep -iqF "y"); then
echo "Will rewrite the .env file with the default one."
>${ENVFILENAME} && for i in "${ENVFILECONTENTS[@]}"; do echo $i >>${ENVFILENAME}; done
echo "Opening enviroment file in nano editor."
nano ${ENVFILENAME}
echo "All done."
else
echo "File already exists with no overwrite permissiong given."
echo "Not doing anything."
fi