Code Update

This commit is contained in:
Christer Warén
2025-06-23 09:35:37 +03:00
parent eb14aa46ff
commit fe56c50bfb
4 changed files with 30 additions and 28 deletions

View File

@ -13,7 +13,7 @@ wx-login(){
elif [[ $(hostname -d) = *"devices.christerwaren.fi" ]] elif [[ $(hostname -d) = *"devices.christerwaren.fi" ]]
then then
ORG=cwchristerw ORG=cwchristerw
elif [[ $USER != "root" && $USER != "local" && -f "$HOME/.warengroup/config.json" && $(cat $HOME/.warengroup/config.json | jq -r .org) ]] elif [[ $USER != "root" && $USER != "local" && -f "$HOME/.warengroup/config.json" && $(cat $HOME/.warengroup/config.json | jq -r .org) != "null" ]]
then then
ORG=$(cat $HOME/.warengroup/config.json | jq -r .org) ORG=$(cat $HOME/.warengroup/config.json | jq -r .org)
else else

View File

@ -1,19 +1,15 @@
wx-start(){ wx-start(){
wx-header "Warén CLI" h1 wx-header "Warén CLI" h1
if [[ $USER != "root" && $USER != "local" ]] mkdir -p $HOME/.warengroup &> /dev/null
if [[ ! -f "$HOME/.warengroup/config.json" || $(cat $HOME/.warengroup/config.json | jq -e . >/dev/null 2>&1 | echo ${PIPESTATUS[1]}) -gt 0 ]]
then then
mkdir -p $HOME/.warengroup &> /dev/null echo '{}' | jq > $HOME/.warengroup/config.json
touch $HOME/.warengroup/config.json &> /dev/null
if [[ ! -f "$HOME/.warengroup/config.json" || $(cat $HOME/.warengroup/config.json | jq -e . >/dev/null 2>&1 | echo ${PIPESTATUS[1]}) -gt 0 ]]
then
echo '{}' | jq > $HOME/.warengroup/config.json
fi
mkdir -p $HOME/.ssh/keys
chmod 700 -R $HOME/.ssh/keys
mkdir -p $HOME/.ssh/multiplex
chmod 700 -R $HOME/.ssh/multiplex
fi fi
mkdir -p $HOME/.ssh/keys
chmod 700 -R $HOME/.ssh/keys
mkdir -p $HOME/.ssh/multiplex
chmod 700 -R $HOME/.ssh/multiplex
} }

View File

@ -5,5 +5,10 @@ wx-stop (){
wx-install --auto wx-install --auto
if [[ $USERNAME != $USER && $USERNAME != $SUDO_USER && $USERNAME != $LOGNAME ]]
then
wx-logout
fi
exit 1 exit 1
} }

29
wx
View File

@ -64,21 +64,17 @@ wx-restricted(){
wx-start(){ wx-start(){
wx-header "Warén CLI" h1 wx-header "Warén CLI" h1
if [[ $USER != "root" && $USER != "local" ]] mkdir -p $HOME/.warengroup &> /dev/null
if [[ ! -f "$HOME/.warengroup/config.json" || $(cat $HOME/.warengroup/config.json | jq -e . >/dev/null 2>&1 | echo ${PIPESTATUS[1]}) -gt 0 ]]
then then
mkdir -p $HOME/.warengroup &> /dev/null echo '{}' | jq > $HOME/.warengroup/config.json
touch $HOME/.warengroup/config.json &> /dev/null
if [[ ! -f "$HOME/.warengroup/config.json" || $(cat $HOME/.warengroup/config.json | jq -e . >/dev/null 2>&1 | echo ${PIPESTATUS[1]}) -gt 0 ]]
then
echo '{}' | jq > $HOME/.warengroup/config.json
fi
mkdir -p $HOME/.ssh/keys
chmod 700 -R $HOME/.ssh/keys
mkdir -p $HOME/.ssh/multiplex
chmod 700 -R $HOME/.ssh/multiplex
fi fi
mkdir -p $HOME/.ssh/keys
chmod 700 -R $HOME/.ssh/keys
mkdir -p $HOME/.ssh/multiplex
chmod 700 -R $HOME/.ssh/multiplex
} }
wx-stop (){ wx-stop (){
@ -88,6 +84,11 @@ wx-stop (){
wx-install --auto wx-install --auto
if [[ $USERNAME != $USER && $USERNAME != $SUDO_USER && $USERNAME != $LOGNAME ]]
then
wx-logout
fi
exit 1 exit 1
} }
@ -244,7 +245,7 @@ wx-login(){
elif [[ $(hostname -d) = *"devices.christerwaren.fi" ]] elif [[ $(hostname -d) = *"devices.christerwaren.fi" ]]
then then
ORG=cwchristerw ORG=cwchristerw
elif [[ $USER != "root" && $USER != "local" && -f "$HOME/.warengroup/config.json" && $(cat $HOME/.warengroup/config.json | jq -r .org) ]] elif [[ $USER != "root" && $USER != "local" && -f "$HOME/.warengroup/config.json" && $(cat $HOME/.warengroup/config.json | jq -r .org) != "null" ]]
then then
ORG=$(cat $HOME/.warengroup/config.json | jq -r .org) ORG=$(cat $HOME/.warengroup/config.json | jq -r .org)
else else