Browse Source

Update edgemax.sh

fixed formatting and some added some quotation marks to make Travis Happy.
pull/1226/head
Evan Swendsen 7 years ago
committed by GitHub
parent
commit
2b129b9aba
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 62
      deploy/edgemax.sh

62
deploy/edgemax.sh

@ -14,10 +14,10 @@
######## Public functions ##################### ######## Public functions #####################
function atexit() { function atexit() {
#closes CLI session
cli-shell-api teardownSession
_debug EXITCODE: $1
return $1
#closes CLI session
cli-shell-api teardownSession
_debug EXITCODE: "$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")"
vals=$( cli-shell-api returnEffectiveValue service gui cert-file)
_info "$(__green "Checking EdgeMax Config for SSL Settings: $lighttpd_pem")"
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"
_info "Certfile is not set to $lighttpd_pem"
_debug "Current Edgemax Certfile" "$certfile"
_info "Certfile is not set to $lighttpd_pem"
# Obtain session environment
session_env=$(cli-shell-api getSessionEnv $PPID)
eval $session_env
vyatta_sbindir="/opt/vyatta/sbin" #overwritten by eval command but needed to pass github checks.
# Obtain session environment
session_env=$(cli-shell-api getSessionEnv $PPID)
eval "$session_env"
# Setup the session
cli-shell-api setupSession
# Setup the session
cli-shell-api setupSession
# Verify Session Started
cli-shell-api inSession
if [ $? -ne 0 ]; then
_err "Something went wrong starting CLI Session!"
atexit 1
fi
SET=${vyatta_sbindir}/my_set
COMMIT=${vyatta_sbindir}/my_commit
SAVE=${vyatta_sbindir}/vyatta-save-config.pl
_info "Setting Certificate parameter."
$SET service gui cert-file /config/auth/le-cert.pem
$COMMIT
$SAVE
else
# Verify Session Started
cli-shell-api inSession
if [ $? -ne 0 ]; then
_err "Something went wrong starting CLI Session!"
atexit 1
fi
SET=${vyatta_sbindir}/my_set
COMMIT=${vyatta_sbindir}/my_commit
SAVE=${vyatta_sbindir}/vyatta-save-config.pl
_info "Setting Certificate parameter."
$SET service gui cert-file /config/auth/le-cert.pem
$COMMIT
$SAVE
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
} }
Loading…
Cancel
Save