88# Interactive grommunio setup
99
1010if [ " $( id -u) " -ne 0 ]; then
11- exec sudo " ${BASH_SOURCE[0]} "
11+ exec sudo " ${BASH_SOURCE[0]} "
12+ fi
13+
14+ CFG_FILE=' /etc/grommunio-setup/grommunio-setup.conf'
15+ PKGED_CFG_FILE=' /etc/grommunio-setup/packaged.conf'
16+ PROGNAME=` basename " $0 " `
17+
18+ # Process command line arguments
19+ USAGE=" Usage: $PROGNAME [-ahx]"
20+ usage () {
21+ echo " $USAGE " 1>&2
22+ exit 2
23+ }
24+
25+ usage_full () {
26+ echo " $USAGE " 1>&2
27+ echo " " 1>&2
28+ echo " -a --apt-setup Set up apt" 1>&2
29+ echo " -h --help This help" 1>&2
30+ echo " -x --no-apt-setup Don't set up apt" 1>&2
31+ echo " " 1>&2
32+ exit 2
33+ }
34+
35+ OPTS=$( getopt -o ahx -l apt-setup,help,no-apt-setup -n " $PROGNAME " -- " $@ " )
36+ if [ $? -ne 0 ]; then
37+ echo " ${PROGNAME} : Failed to parse options." 1>&2
38+ exit 2
39+ fi
40+ # Reset the positional parameters to the parsed options
41+ eval set -- " $OPTS "
42+
43+ # setable settings here
44+ NO_APT_SETUP=0
45+ [ -e " $CFG_FILE " ] && . " $CFG_FILE "
46+ # override various settings for packaged setup script
47+ [ -e " $PKGED_CFG_FILE " ] && . " $PKGED_CFG_FILE "
48+ # Unsettable settings here
49+ # Process the options
50+ while true ; do
51+ case " $1 " in
52+ -a | --apt-setup)
53+ NO_APT_SETUP=0
54+ shift
55+ ;;
56+ -h | --help)
57+ usage_full
58+ shift
59+ ;;
60+ -x | --no-apt-setup)
61+ NO_APT_SETUP=1
62+ shift
63+ ;;
64+ --)
65+ shift
66+ break
67+ ;;
68+ * )
69+ echo " ${PROGNAME} : Internal error!"
70+ exit 2
71+ ;;
72+ esac
73+ done
74+
75+ if [ $# -ne 0 ]; then
76+ usage
1277fi
1378
1479export DEBIAN_FRONTEND=noninteractive
@@ -26,9 +91,6 @@ if ! test -e "$LOGFILE"; then
2691 true > " $LOGFILE "
2792 chmod 0600 " $LOGFILE "
2893fi
29- if [ " $1 " = " JUSTDOIT" ]; then
30- SKIPDIALOG=1
31- fi
3294
3395apt-get () {
3496if [ " $1 " = " update" ]; then
@@ -106,17 +168,17 @@ You can abort or delete all data and setup everything from scratch. If so, confi
106168\Z1If you continue, ALL data wil be removed!\Z1' \
107169 0 0 3>&1 1>&2 2>&3 )
108170 dialog_exit $?
109-
110171 if [ " ${DELCONFIRM} " != " removealldata" ]; then
111172 writelog " Aborted deletion after detected existing installation"
112173 exit 0
113174 else
114175 writelog " Deleting existing installation after confirmation"
115176 echo " drop database grommunio;" | mysql
116- # remove folders
177+ # remove folders etc
117178 rm -Rf /var/lib/gromox/* \
118179 /etc/grommunio-common/ssl/* \
119180 /etc/grommunio-common/setup_done \
181+ /etc/apt/sources.list.d/grommunio.sources \
120182 /var/lib/grommunio-web/*
121183
122184 # recreate them..
@@ -172,7 +234,15 @@ PACKAGES=(gromox grommunio-admin-api grommunio-admin-web grommunio-index
172234 grommunio-admin-common grommunio-common grommunio-web grommunio-sync
173235 grommunio-dav grommunio-dbconf nginx-module-vts)
174236. " ${DATADIR} /common/repo"
175- setup_repo
237+ if [ $NO_APT_SETUP -eq 0 ]; then
238+ setup_repo
239+ if [ $? -ne 0 ]; then
240+ writelog " Exiting - trying to set up apt repos when already defined"
241+ apt_already_setup_notice
242+ clear
243+ exit 2
244+ fi
245+ fi
176246writelog " Installing Grommunio-Packages"
177247apt-get update
178248# reinstall in case of "removealldata"
@@ -370,8 +440,8 @@ choose_ssl_selfprovided() {
370440 writelog " Dialog: data for self-provided TLS cert"
371441 dialog --no-mouse --colors --backtitle " grommunio Setup" --title " TLS certificate (self-provided)" --ok-label " Submit" \
372442 --form " Enter the paths to the TLS certificates" 0 0 0 \
373- " PEM encoded certificate bundle: " 1 1 " ${SSL_BUNDLE} " 1 35 35 0 \
374- " PEM encoded private key: " 2 1 " ${SSL_KEY} " 2 35 35 0 2> " ${TMPF} "
443+ " PEM encoded certificate bundle: " 1 1 " ${SSL_BUNDLE} " 1 35 120 0 \
444+ " PEM encoded private key: " 2 1 " ${SSL_KEY} " 2 35 120 0 2> " ${TMPF} "
375445 dialog_exit $?
376446
377447}
0 commit comments