Init: Update
This commit is contained in:
1 parent
67031bea2d
commit
82930fd1b7
1 file changed
+68
-79
@@ -153,85 +153,6 @@ wxi-config-legacy(){
|
||||
mv $WX_HOME/config.json.tmp $WX_HOME/config.json &> /dev/null
|
||||
}
|
||||
|
||||
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-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-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-stop
|
||||
;;
|
||||
esac
|
||||
else
|
||||
wxi-content status "Organization" "Required"
|
||||
wxi-stop
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ -z $1 || $1 == "--vault" ]]
|
||||
then
|
||||
if [[ -z $VAULT_DOMAIN ]]
|
||||
then
|
||||
wxi-content status "Vault" "Unavailable"
|
||||
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-repeat "\n" 3
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
wxi-init(){
|
||||
wx-login
|
||||
wxi-header "Init"
|
||||
@@ -308,6 +229,74 @@ wxi-init(){
|
||||
unset HVT
|
||||
}
|
||||
|
||||
wxi-restricted(){
|
||||
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-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-stop
|
||||
;;
|
||||
esac
|
||||
else
|
||||
wxi-content status "Organization" "Required"
|
||||
wxi-stop
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ -z $1 || $1 == "--vault" ]]
|
||||
then
|
||||
if [[ -z $VAULT_DOMAIN ]]
|
||||
then
|
||||
wxi-content status "Vault" "Unavailable"
|
||||
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-repeat "\n" 3
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
wxi-start(){
|
||||
wxi-header "Warén Group / Infra / Init" h1
|
||||
|
||||
|
||||
Reference in new issue
Block a user