Update edgemax.sh

fixed formatting and some added some quotation marks to make Travis Happy.
This commit is contained in:
Evan Swendsen 2018-01-29 11:52:25 -07:00 committed by GitHub
parent e0d630d7a9
commit 2b129b9aba
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -14,10 +14,10 @@
######## Public functions ##################### ######## Public functions #####################
function atexit() { function atexit() {
#closes CLI session #closes CLI session
cli-shell-api teardownSession cli-shell-api teardownSession
_debug EXITCODE: $1 _debug EXITCODE: "$1"
return $1 return "$1"
} }
@ -28,12 +28,11 @@ edgemax_deploy() {
_ccert="$3" _ccert="$3"
_cca="$4" _cca="$4"
_cfullchain="$5" _cfullchain="$5"
### 'lighttpd_pem' - certificate file configured for your Edgemax GUI ### 'lighttpd_pem' - certificate file configured for your Edgemax GUI
lighttpd_pem=/config/auth/le-cert.pem lighttpd_pem=/config/auth/le-cert.pem
_info "$(__green "EdgeMax Certificate Path: $lighttpd_pem")" _info "$(__green "EdgeMax Certificate Path: $lighttpd_pem")"
_debug _cdomain "$_cdomain" _debug _cdomain "$_cdomain"
_debug _ckey "$_ckey" _debug _ckey "$_ckey"
_debug _ccert "$_ccert" _debug _ccert "$_ccert"
@ -42,40 +41,41 @@ edgemax_deploy() {
_info "Generating PEM file for lighttpd" _info "Generating PEM file for lighttpd"
sudo sh -c "cat ${_ccert} ${_ckey} > ${lighttpd_pem}" sudo sh -c "cat ${_ccert} ${_ckey} > ${lighttpd_pem}"
_info "$(__green "Checking EdgeMax Config for SSL Settings: $lighttpd_pem")" _info "$(__green "Checking EdgeMax Config for SSL Settings: $lighttpd_pem")"
vals=$( cli-shell-api returnEffectiveValue service gui cert-file) vals=$(cli-shell-api returnEffectiveValue service gui cert-file)
certfile=$vals certfile=$vals
if [ "$lighttpd_pem" != "$certfile" ]; then if [ "$lighttpd_pem" != "$certfile" ]; then
_debug "Current Edgemax Certfile" "$certfile" _debug "Current Edgemax Certfile" "$certfile"
_info "Certfile is not set to $lighttpd_pem" _info "Certfile is not set to $lighttpd_pem"
# Obtain session environment vyatta_sbindir="/opt/vyatta/sbin" #overwritten by eval command but needed to pass github checks.
session_env=$(cli-shell-api getSessionEnv $PPID) # Obtain session environment
eval $session_env session_env=$(cli-shell-api getSessionEnv $PPID)
eval "$session_env"
# Setup the session # Setup the session
cli-shell-api setupSession cli-shell-api setupSession
# Verify Session Started # Verify Session Started
cli-shell-api inSession cli-shell-api inSession
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
_err "Something went wrong starting CLI Session!" _err "Something went wrong starting CLI Session!"
atexit 1 atexit 1
fi fi
SET=${vyatta_sbindir}/my_set SET=${vyatta_sbindir}/my_set
COMMIT=${vyatta_sbindir}/my_commit COMMIT=${vyatta_sbindir}/my_commit
SAVE=${vyatta_sbindir}/vyatta-save-config.pl SAVE=${vyatta_sbindir}/vyatta-save-config.pl
_info "Setting Certificate parameter." _info "Setting Certificate parameter."
$SET service gui cert-file /config/auth/le-cert.pem $SET service gui cert-file /config/auth/le-cert.pem
$COMMIT $COMMIT
$SAVE $SAVE
else else
_info "EdgeMax cert-file already set to $lighttpd_pem" _info "EdgeMax cert-file already set to $lighttpd_pem"
fi fi
_info Restarting lighttpd _info Restarting lighttpd
sudo kill -SIGTERM $(cat /var/run/lighttpd.pid) sudo kill -SIGTERM $(cat /var/run/lighttpd.pid)
sudo /usr/sbin/lighttpd -f /etc/lighttpd/lighttpd.conf sudo /usr/sbin/lighttpd -f /etc/lighttpd/lighttpd.conf
atexit 0 atexit 0
} }