85 lines
1.9 KiB
Bash
85 lines
1.9 KiB
Bash
wxi-restricted(){
|
|
if [[ -z $1 || $1 == "--user" ]]
|
|
then
|
|
if [[ $USER == "root" || $USER == "local" ]]
|
|
then
|
|
wxi-content status "Command" "Restricted"
|
|
wxi-content text "It's not permitted to execute this command with root or local user."
|
|
wxi-footer
|
|
wxi-repeat "\n" 3
|
|
exit 1
|
|
fi
|
|
fi
|
|
|
|
if [[ $1 == "--org" ]]
|
|
then
|
|
if [[ ! -z ${args['org']} ]]
|
|
then
|
|
case ${args['org']} in
|
|
warengroup)
|
|
ORG=warengroup
|
|
;;
|
|
cwchristerw)
|
|
ORG=cwchristerw
|
|
;;
|
|
*)
|
|
wxi-content status "Organization" "Unsupported"
|
|
wxi-footer
|
|
wxi-stop
|
|
;;
|
|
esac
|
|
elif [[ $(hostname -d) == "devices.waren.io" ]]
|
|
then
|
|
ORG=warengroup
|
|
elif [[ $(hostname -d) == "devices.christerwaren.fi" ]]
|
|
then
|
|
ORG=cwchristerw
|
|
fi
|
|
|
|
if [[ ! -z $ORG ]]
|
|
then
|
|
case $ORG in
|
|
warengroup)
|
|
DOMAIN=waren.io
|
|
VAULT_DOMAIN=vault.cwinfo.net
|
|
ORG_HEADER="Warén Group"
|
|
;;
|
|
cwchristerw)
|
|
DOMAIN=christerwaren.fi
|
|
VAULT_DOMAIN=vault.cwinfo.net
|
|
ORG_HEADER="Christer Warén"
|
|
;;
|
|
*)
|
|
wxi-content status "Organization" "Unsupported"
|
|
wxi-footer
|
|
wxi-stop
|
|
;;
|
|
esac
|
|
else
|
|
wxi-content status "Organization" "Required"
|
|
wxi-footer
|
|
wxi-stop
|
|
fi
|
|
fi
|
|
|
|
if [[ -z $1 || $1 == "--vault" ]]
|
|
then
|
|
if [[ -z $VAULT_DOMAIN ]]
|
|
then
|
|
wxi-content status "Vault" "Unavailable"
|
|
wxi-footer
|
|
wxi-repeat "\n" 3
|
|
exit 1
|
|
fi
|
|
|
|
VAULT_STATUS=$(curl -s -o /dev/null -w "%{http_code}" https://$VAULT_DOMAIN/v1/sys/health)
|
|
if [[ ! $VAULT_STATUS -eq 200 ]]
|
|
then
|
|
wxi-content status "Vault" "Offline"
|
|
wxi-footer
|
|
wxi-repeat "\n" 3
|
|
exit 1
|
|
fi
|
|
fi
|
|
}
|