From 4aab6c3c9ba6c395bcf975eea0b90119439a8fbf Mon Sep 17 00:00:00 2001 From: Jakob Stendahl Date: Wed, 5 Dec 2018 23:06:59 +0100 Subject: :sparkles: Improve status function, add enable/disable start on boot --- bin/luxcena-neo-cli.sh | 40 +++++++++++++++++++++++++++++++++++----- 1 file changed, 35 insertions(+), 5 deletions(-) (limited to 'bin') diff --git a/bin/luxcena-neo-cli.sh b/bin/luxcena-neo-cli.sh index 180b0c4..0dfc6d8 100755 --- a/bin/luxcena-neo-cli.sh +++ b/bin/luxcena-neo-cli.sh @@ -68,9 +68,6 @@ if [ "$action" == "update" ]; then runuser -l 'lux-neo' -c 'export NODE_ENV=production; npm --prefix ~/src install ~/src --only=production' cp /home/lux-neo/src/bin/luxcena-neo-cli.sh /usr/bin/luxcena-neo-cli.sh printf "Update complete.\n" - #printf "Update complete, run these commands to finish it completly:\n" - #printf "sudo /home/lux-neo/src/bin/post-update.sh\n" - #printf "sudo systemctl luxcena-neo start\n" systemctl start luxcena-neo elif [ "$action" == "uninstall" ]; then @@ -106,12 +103,45 @@ elif [ "$action" == "conf" ]; then elif [ "$action" == "start" ]; then systemctl start luxcena-neo + if [ "$2" == "boot" ]; then + systemctl enable luxcena-neo + printf "Now starting on boot...\n" + printf "Luxcena-neo service started...\n" + elif [ "$action" == "stop" ]; then systemctl stop luxcena-neo + if [ "$2" == "boot" ]; then + systemctl disable luxcena-neo + printf "Not longer active on boot...\n" + printf "Luxcena-neo service stopped...\n" + elif [ "$action" == "status" ]; then - printf '\e[93m%s\e[0m\n' "---Service status------------------" + printf "╭─────────────────────╮\n" + printf "│ Service active: " + [ $(systemctl is-active lucxena-neo) -eq "active" ] && printf '\e[32m%s\e[0m │\n' "yes" || printf '\e[31m%s\e[0m │\n' "no" + printf "│ Starts on boot: " + [ $(systemctl is-enabled lucxena-neo) -eq "enabled" ] && printf '\e[32m%s\e[0m │\n' "yes" || printf '\e[31m%s\e[0m │\n' "no" + printf "│ Has failed: " + [ $(systemctl is-failed lucxena-neo) -eq "failed" ] && printf '\e[32m%s\e[0m │\n' "yes" || printf '\e[31m%s\e[0m │\n' "no" + printf "╰─────────────────────╯\n\n" + + printf '\e[93m%s\e[0m\n' "━━━Service status━━━━━━━━━━━━━━━━━━" systemctl status luxcena-neo - printf '\e[93m%s\e[0m\n' "-----------------------------------" + printf '\e[93m%s\e[0m\n' "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" + +elif [ "$action" == "log" ]; then + if [ "$2" == "sevice" ]; then + printf '\e[93m%s\e[0m\n' "━━━Service log (press ctrl+c to exit)━━━━━━━━━━━━━━━━━━" + tail -F -n 20 /home/lux-neo/logs/service.log + if [ "$2" == "app" ]; then + printf '\e[93m%s\e[0m\n' "━━━App log (press ctrl+c to exit)━━━━━━━━━━━━━━━━━━" + tail -F -n 20 /home/lux-neo/logs/logger.log + +elif [ "$action" == "version" ] || [ "$action" == "v" ]; then + printf "Version: Unknown\n" + +elif [ "$action" == "selectBranch" ] + printf "Current Branch \n" else usage fi -- cgit v1.2.3 From 069552dc479a6c420d6440c9fdefb4ddf63eac08 Mon Sep 17 00:00:00 2001 From: Jakob Stendahl Date: Wed, 5 Dec 2018 23:12:12 +0100 Subject: :hammer: Fix syntax --- bin/luxcena-neo-cli.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'bin') diff --git a/bin/luxcena-neo-cli.sh b/bin/luxcena-neo-cli.sh index 0dfc6d8..60adefd 100755 --- a/bin/luxcena-neo-cli.sh +++ b/bin/luxcena-neo-cli.sh @@ -106,6 +106,7 @@ elif [ "$action" == "start" ]; then if [ "$2" == "boot" ]; then systemctl enable luxcena-neo printf "Now starting on boot...\n" + fi printf "Luxcena-neo service started...\n" elif [ "$action" == "stop" ]; then @@ -113,6 +114,7 @@ elif [ "$action" == "stop" ]; then if [ "$2" == "boot" ]; then systemctl disable luxcena-neo printf "Not longer active on boot...\n" + fi printf "Luxcena-neo service stopped...\n" elif [ "$action" == "status" ]; then @@ -133,14 +135,16 @@ elif [ "$action" == "log" ]; then if [ "$2" == "sevice" ]; then printf '\e[93m%s\e[0m\n' "━━━Service log (press ctrl+c to exit)━━━━━━━━━━━━━━━━━━" tail -F -n 20 /home/lux-neo/logs/service.log + fi if [ "$2" == "app" ]; then printf '\e[93m%s\e[0m\n' "━━━App log (press ctrl+c to exit)━━━━━━━━━━━━━━━━━━" tail -F -n 20 /home/lux-neo/logs/logger.log + fi elif [ "$action" == "version" ] || [ "$action" == "v" ]; then printf "Version: Unknown\n" -elif [ "$action" == "selectBranch" ] +elif [ "$action" == "selectBranch" ]; then printf "Current Branch \n" else usage -- cgit v1.2.3 From a02968d77a3933311d8f6869967b75dad301705a Mon Sep 17 00:00:00 2001 From: Jakob Stendahl Date: Wed, 5 Dec 2018 23:21:22 +0100 Subject: :hammer: Fix typos and syntax --- bin/luxcena-neo-cli.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'bin') diff --git a/bin/luxcena-neo-cli.sh b/bin/luxcena-neo-cli.sh index 60adefd..a2b2336 100755 --- a/bin/luxcena-neo-cli.sh +++ b/bin/luxcena-neo-cli.sh @@ -120,11 +120,11 @@ elif [ "$action" == "stop" ]; then elif [ "$action" == "status" ]; then printf "╭─────────────────────╮\n" printf "│ Service active: " - [ $(systemctl is-active lucxena-neo) -eq "active" ] && printf '\e[32m%s\e[0m │\n' "yes" || printf '\e[31m%s\e[0m │\n' "no" + [[ "$(systemctl is-active lucxena-neo)" == *"active"* ]] && printf '\e[32m%s\e[0m │\n' "yes" || printf '\e[31m%s\e[0m │\n' "no" printf "│ Starts on boot: " - [ $(systemctl is-enabled lucxena-neo) -eq "enabled" ] && printf '\e[32m%s\e[0m │\n' "yes" || printf '\e[31m%s\e[0m │\n' "no" + [[ "$(systemctl is-enabled lucxena-neo)" == *"enabled"* ]] && printf '\e[32m%s\e[0m │\n' "yes" || printf '\e[31m%s\e[0m │\n' "no" printf "│ Has failed: " - [ $(systemctl is-failed lucxena-neo) -eq "failed" ] && printf '\e[32m%s\e[0m │\n' "yes" || printf '\e[31m%s\e[0m │\n' "no" + [[ "$(systemctl is-failed lucxena-neo)" == *"failed"* ]] && printf '\e[32m%s\e[0m │\n' "yes" || printf '\e[31m%s\e[0m │\n' "no" printf "╰─────────────────────╯\n\n" printf '\e[93m%s\e[0m\n' "━━━Service status━━━━━━━━━━━━━━━━━━" @@ -132,7 +132,7 @@ elif [ "$action" == "status" ]; then printf '\e[93m%s\e[0m\n' "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" elif [ "$action" == "log" ]; then - if [ "$2" == "sevice" ]; then + if [ "$2" == "service" ]; then printf '\e[93m%s\e[0m\n' "━━━Service log (press ctrl+c to exit)━━━━━━━━━━━━━━━━━━" tail -F -n 20 /home/lux-neo/logs/service.log fi -- cgit v1.2.3 From ddfa2c672e0a6d8e10720d55a42c3ba453acdd85 Mon Sep 17 00:00:00 2001 From: Jakob Stendahl Date: Wed, 5 Dec 2018 23:25:15 +0100 Subject: :hammer: Add skipNode on update, and typo --- bin/luxcena-neo-cli.sh | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'bin') diff --git a/bin/luxcena-neo-cli.sh b/bin/luxcena-neo-cli.sh index a2b2336..65f2d6d 100755 --- a/bin/luxcena-neo-cli.sh +++ b/bin/luxcena-neo-cli.sh @@ -65,10 +65,15 @@ if [ "$action" == "update" ]; then systemctl stop luxcena-neo runuser -l 'lux-neo' -c 'git -C ~/src pull' - runuser -l 'lux-neo' -c 'export NODE_ENV=production; npm --prefix ~/src install ~/src --only=production' + + if [ "$2" != "skipNode" ]; then + runuser -l 'lux-neo' -c 'export NODE_ENV=production; npm --prefix ~/src install ~/src --only=production' + fi + cp /home/lux-neo/src/bin/luxcena-neo-cli.sh /usr/bin/luxcena-neo-cli.sh printf "Update complete.\n" systemctl start luxcena-neo + exit 0 elif [ "$action" == "uninstall" ]; then tput setab 1 @@ -120,11 +125,11 @@ elif [ "$action" == "stop" ]; then elif [ "$action" == "status" ]; then printf "╭─────────────────────╮\n" printf "│ Service active: " - [[ "$(systemctl is-active lucxena-neo)" == *"active"* ]] && printf '\e[32m%s\e[0m │\n' "yes" || printf '\e[31m%s\e[0m │\n' "no" + [[ "$(systemctl is-active luxcena-neo)" == *"active"* ]] && printf '\e[32m%s\e[0m │\n' "yes" || printf '\e[31m%s\e[0m │\n' "no" printf "│ Starts on boot: " - [[ "$(systemctl is-enabled lucxena-neo)" == *"enabled"* ]] && printf '\e[32m%s\e[0m │\n' "yes" || printf '\e[31m%s\e[0m │\n' "no" + [[ "$(systemctl is-enabled luxcena-neo)" == *"enabled"* ]] && printf '\e[32m%s\e[0m │\n' "yes" || printf '\e[31m%s\e[0m │\n' "no" printf "│ Has failed: " - [[ "$(systemctl is-failed lucxena-neo)" == *"failed"* ]] && printf '\e[32m%s\e[0m │\n' "yes" || printf '\e[31m%s\e[0m │\n' "no" + [[ "$(systemctl is-failed luxcena-neo)" == *"failed"* ]] && printf '\e[32m%s\e[0m │\n' "yes" || printf '\e[31m%s\e[0m │\n' "no" printf "╰─────────────────────╯\n\n" printf '\e[93m%s\e[0m\n' "━━━Service status━━━━━━━━━━━━━━━━━━" -- cgit v1.2.3 From e558550db74f80f947e283a7fbddf5d9d549f68e Mon Sep 17 00:00:00 2001 From: Jakob Stendahl Date: Wed, 5 Dec 2018 23:32:59 +0100 Subject: :construction: Add first line with current command when starting CLI --- bin/luxcena-neo-cli.sh | 3 +++ 1 file changed, 3 insertions(+) (limited to 'bin') diff --git a/bin/luxcena-neo-cli.sh b/bin/luxcena-neo-cli.sh index 65f2d6d..f2b0e9d 100755 --- a/bin/luxcena-neo-cli.sh +++ b/bin/luxcena-neo-cli.sh @@ -49,6 +49,9 @@ while getopts ":a:" o; do done shift $((OPTIND-1)) +printf "\n" +printf "\e[37mLuxcena-neo-cli command: \e[90m'$*'.\n\n\e[0m" + action=$1 if [ "$action" == "update" ]; then -- cgit v1.2.3 From 3ffabe1ba35565df433536a2ba370b0e4967e940 Mon Sep 17 00:00:00 2001 From: Jakob Stendahl Date: Wed, 5 Dec 2018 23:37:47 +0100 Subject: :lipstick: Prettify welcome message --- bin/luxcena-neo-cli.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'bin') diff --git a/bin/luxcena-neo-cli.sh b/bin/luxcena-neo-cli.sh index f2b0e9d..4ecfc0f 100755 --- a/bin/luxcena-neo-cli.sh +++ b/bin/luxcena-neo-cli.sh @@ -49,8 +49,7 @@ while getopts ":a:" o; do done shift $((OPTIND-1)) -printf "\n" -printf "\e[37mLuxcena-neo-cli command: \e[90m'$*'.\n\n\e[0m" +printf "\e[37m> \e[4mLuxcena-\e[31mn\e[34me\e[34mo\e[37-cli command: \e[90m'$*'.\n\n\e[0m" action=$1 if [ "$action" == "update" ]; then -- cgit v1.2.3 From 57f370771399ca0625849d11816067a7af83a5ac Mon Sep 17 00:00:00 2001 From: Jakob Stendahl Date: Wed, 5 Dec 2018 23:39:26 +0100 Subject: :lipstick: Correctyly prettify --- bin/luxcena-neo-cli.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'bin') diff --git a/bin/luxcena-neo-cli.sh b/bin/luxcena-neo-cli.sh index 4ecfc0f..2959dc9 100755 --- a/bin/luxcena-neo-cli.sh +++ b/bin/luxcena-neo-cli.sh @@ -49,7 +49,7 @@ while getopts ":a:" o; do done shift $((OPTIND-1)) -printf "\e[37m> \e[4mLuxcena-\e[31mn\e[34me\e[34mo\e[37-cli command: \e[90m'$*'.\n\n\e[0m" +printf "\e[37m> \e[4mLuxcena-\e[31mn\e[32me\e[34mo\e[37m-cli command: \e[90m'$*'.\n\n\e[0m" action=$1 if [ "$action" == "update" ]; then -- cgit v1.2.3 From d58f59df39ecc93eeb979d2d3da9836b2b5dfb25 Mon Sep 17 00:00:00 2001 From: Jakob Stendahl Date: Wed, 5 Dec 2018 23:41:08 +0100 Subject: :lipstick: Maybe final styling of startmsg? --- bin/luxcena-neo-cli.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'bin') diff --git a/bin/luxcena-neo-cli.sh b/bin/luxcena-neo-cli.sh index 2959dc9..b91d9b3 100755 --- a/bin/luxcena-neo-cli.sh +++ b/bin/luxcena-neo-cli.sh @@ -49,7 +49,7 @@ while getopts ":a:" o; do done shift $((OPTIND-1)) -printf "\e[37m> \e[4mLuxcena-\e[31mn\e[32me\e[34mo\e[37m-cli command: \e[90m'$*'.\n\n\e[0m" +printf "\e[4mLuxcena-\e[31mn\e[32me\e[34mo\e[37m-cli. [args: \e[90m'$*'.\n\n\e[0m]" action=$1 if [ "$action" == "update" ]; then -- cgit v1.2.3 From ff3ba1d6cc29402bd0938baa52e0cdf854a9a745 Mon Sep 17 00:00:00 2001 From: Jakob Stendahl Date: Wed, 5 Dec 2018 23:42:01 +0100 Subject: :prettify: Now we might be getting somewhere with the styling --- bin/luxcena-neo-cli.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'bin') diff --git a/bin/luxcena-neo-cli.sh b/bin/luxcena-neo-cli.sh index b91d9b3..59cf5b5 100755 --- a/bin/luxcena-neo-cli.sh +++ b/bin/luxcena-neo-cli.sh @@ -49,7 +49,7 @@ while getopts ":a:" o; do done shift $((OPTIND-1)) -printf "\e[4mLuxcena-\e[31mn\e[32me\e[34mo\e[37m-cli. [args: \e[90m'$*'.\n\n\e[0m]" +printf "\e[37mLuxcena-\e[31mn\e[32me\e[34mo\e[37m-cli. [args: \e[90m'$*']\n\n\e[0m" action=$1 if [ "$action" == "update" ]; then -- cgit v1.2.3 From 921de6d0023f09db986dbed1c25c4e27196d3fdb Mon Sep 17 00:00:00 2001 From: Jakob Stendahl Date: Wed, 5 Dec 2018 23:48:05 +0100 Subject: :lipstick: Add branch-change func --- bin/luxcena-neo-cli.sh | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'bin') diff --git a/bin/luxcena-neo-cli.sh b/bin/luxcena-neo-cli.sh index 59cf5b5..a3c46bf 100755 --- a/bin/luxcena-neo-cli.sh +++ b/bin/luxcena-neo-cli.sh @@ -49,7 +49,7 @@ while getopts ":a:" o; do done shift $((OPTIND-1)) -printf "\e[37mLuxcena-\e[31mn\e[32me\e[34mo\e[37m-cli. [args: \e[90m'$*']\n\n\e[0m" +printf "\e[37mLuxcena-\e[31mn\e[32me\e[34mo\e[37m-cli \e[90m[args: '$*']\n\n\e[0m" action=$1 if [ "$action" == "update" ]; then @@ -149,10 +149,16 @@ elif [ "$action" == "log" ]; then fi elif [ "$action" == "version" ] || [ "$action" == "v" ]; then - printf "Version: Unknown\n" + printf "╭─────────────────────╮\n" + printf "│ Version: Unknown │\n" + printf "│ branch : $(git branch | grep \* | cut -d ' ' -f2) │\n" + printf "╰─────────────────────╯\n\n" elif [ "$action" == "selectBranch" ]; then - printf "Current Branch \n" + printf "Current $(git branch | grep \* | cut -d ' ' -f2)Branch \n" + runuser -l 'lux-neo' -c "git -C ~/src checkout $2" + printf "\e[91mYou should now run \e[90m'sudo lux-neo update'\e[91m!\n" + else usage fi -- cgit v1.2.3 From 52cd3bb8d9c0f1f63cf30e2a474141e3385069d3 Mon Sep 17 00:00:00 2001 From: Jakob Stendahl Date: Wed, 5 Dec 2018 23:53:19 +0100 Subject: :construction: Add path to branch-checks --- bin/luxcena-neo-cli.sh | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'bin') diff --git a/bin/luxcena-neo-cli.sh b/bin/luxcena-neo-cli.sh index a3c46bf..d744869 100755 --- a/bin/luxcena-neo-cli.sh +++ b/bin/luxcena-neo-cli.sh @@ -151,14 +151,13 @@ elif [ "$action" == "log" ]; then elif [ "$action" == "version" ] || [ "$action" == "v" ]; then printf "╭─────────────────────╮\n" printf "│ Version: Unknown │\n" - printf "│ branch : $(git branch | grep \* | cut -d ' ' -f2) │\n" + printf "│ branch : $(git branch -C /home/lux-neo/src | grep \* | cut -d ' ' -f2) │\n" printf "╰─────────────────────╯\n\n" elif [ "$action" == "selectBranch" ]; then - printf "Current $(git branch | grep \* | cut -d ' ' -f2)Branch \n" - runuser -l 'lux-neo' -c "git -C ~/src checkout $2" - printf "\e[91mYou should now run \e[90m'sudo lux-neo update'\e[91m!\n" - + printf "Current $(git -C /home/lux-neo/src branch | grep \* | cut -d ' ' -f2)Branch \n" + runuser -l 'lux-neo' -c "git -C ~/src checkout $2" || printf "\e[91mYou should now run \e[90m'sudo lux-neo update'\e[91m!\n" + else usage fi -- cgit v1.2.3 From c1392518922a6438c6828f3eb271a60163e011c6 Mon Sep 17 00:00:00 2001 From: Jakob Stendahl Date: Wed, 5 Dec 2018 23:55:17 +0100 Subject: :construction: Make branch check work --- bin/luxcena-neo-cli.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'bin') diff --git a/bin/luxcena-neo-cli.sh b/bin/luxcena-neo-cli.sh index d744869..ba55d36 100755 --- a/bin/luxcena-neo-cli.sh +++ b/bin/luxcena-neo-cli.sh @@ -151,13 +151,13 @@ elif [ "$action" == "log" ]; then elif [ "$action" == "version" ] || [ "$action" == "v" ]; then printf "╭─────────────────────╮\n" printf "│ Version: Unknown │\n" - printf "│ branch : $(git branch -C /home/lux-neo/src | grep \* | cut -d ' ' -f2) │\n" + printf "│ branch : $(git -C /home/lux-neo/src branch | grep \* | cut -d ' ' -f2) │\n" printf "╰─────────────────────╯\n\n" elif [ "$action" == "selectBranch" ]; then printf "Current $(git -C /home/lux-neo/src branch | grep \* | cut -d ' ' -f2)Branch \n" runuser -l 'lux-neo' -c "git -C ~/src checkout $2" || printf "\e[91mYou should now run \e[90m'sudo lux-neo update'\e[91m!\n" - + else usage fi -- cgit v1.2.3 From e56c60e17f5060203c993c852272e795b3ee6224 Mon Sep 17 00:00:00 2001 From: Jakob Stendahl Date: Thu, 6 Dec 2018 00:15:57 +0100 Subject: :construction: Stash before changing branch --- bin/luxcena-neo-cli.sh | 1 + 1 file changed, 1 insertion(+) (limited to 'bin') diff --git a/bin/luxcena-neo-cli.sh b/bin/luxcena-neo-cli.sh index ba55d36..defb766 100755 --- a/bin/luxcena-neo-cli.sh +++ b/bin/luxcena-neo-cli.sh @@ -156,6 +156,7 @@ elif [ "$action" == "version" ] || [ "$action" == "v" ]; then elif [ "$action" == "selectBranch" ]; then printf "Current $(git -C /home/lux-neo/src branch | grep \* | cut -d ' ' -f2)Branch \n" + runuser -l 'lux-neo' -c "git -C ~/src stash" runuser -l 'lux-neo' -c "git -C ~/src checkout $2" || printf "\e[91mYou should now run \e[90m'sudo lux-neo update'\e[91m!\n" else -- cgit v1.2.3