From 66cd58823ff7cb5ab090e879b49cb616619e7b9d Mon Sep 17 00:00:00 2001 From: Jakob Stendahl <14180120+JakobST1n@users.noreply.github.com> Date: Thu, 14 Oct 2021 13:13:22 +0200 Subject: :hammer: Attempt to fix updater url --- src/SelfUpdater/index.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/SelfUpdater/index.js b/src/SelfUpdater/index.js index f332e27..28bb65a 100644 --- a/src/SelfUpdater/index.js +++ b/src/SelfUpdater/index.js @@ -16,10 +16,11 @@ class VersionChecker { this.checkFrequency = neoModules.userData.config.SelfUpdater.checkVersionInterval * 86400000; // Takes in days. this.repoBranch = neoModules.userData.config.SelfUpdater.branch; - this.remotePackageJSON = "https://raw.githubusercontent.com" + url.parse(this.repoLink).pathname + "/" + this.repoBranch + "/package.json"; + this.remotePackageJSON = "https://raw.githubusercontent.com/JakobST1n/Luxcena-Neo/" + this.repoBranch + "/package.json"; this.newVersion = false; - this.newestVersion = this.checkVersion(this.remotePackageJSON); + this.newestVersion = this.version; + this.checkVersion(this.remotePackageJSON); this.updateChecker = setInterval(() => { let newVersion = this.checkVersion(this.remotePackageJSON); @@ -31,15 +32,14 @@ class VersionChecker { request.get(this.remotePackageJSON, (error, response, body) => { if (!error && response.statusCode === 200) { let remotePackageJSON = JSON.parse(body); - let newestVersion = remotePackageJSON["version"]; - if (newestVersion != this.version) { + this.newestVersion = remotePackageJSON["version"]; + if (this.newestVersion != this.version) { logger.notice("A new version is available on \"" + this.repoBranch + "\" (v" + this.version + ")"); this.newVersion = true; } else { logger.info(`Running newest version (${newestVersion})`); this.newVersion = false; } - this.newestVersion = newestVersion; } else { logger.notice("Could not find latest version! Please check you internet connection."); } -- cgit v1.2.3 From 9ebd478e72f1635ad38277e6e9f5ad8649eedbfe Mon Sep 17 00:00:00 2001 From: Jakob Stendahl <14180120+JakobST1n@users.noreply.github.com> Date: Thu, 14 Oct 2021 13:15:48 +0200 Subject: :construction: Update script --- src/SelfUpdater/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SelfUpdater/index.js b/src/SelfUpdater/index.js index 28bb65a..4292c74 100644 --- a/src/SelfUpdater/index.js +++ b/src/SelfUpdater/index.js @@ -37,7 +37,7 @@ class VersionChecker { logger.notice("A new version is available on \"" + this.repoBranch + "\" (v" + this.version + ")"); this.newVersion = true; } else { - logger.info(`Running newest version (${newestVersion})`); + logger.info(`Running newest version (${this.newestVersion})`); this.newVersion = false; } } else { -- cgit v1.2.3 From 9586c1e997368c646c673bd6026214a10bf55357 Mon Sep 17 00:00:00 2001 From: Jakob Stendahl <14180120+JakobST1n@users.noreply.github.com> Date: Fri, 15 Oct 2021 12:19:41 +0200 Subject: :hammer: Make update script start in it's own shell --- src/SelfUpdater/index.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/SelfUpdater/index.js b/src/SelfUpdater/index.js index 4292c74..e9bd4c7 100644 --- a/src/SelfUpdater/index.js +++ b/src/SelfUpdater/index.js @@ -64,7 +64,8 @@ class VersionChecker { spawn("luxcena-neo-cli.sh", ["update", ">>", "/tmp/luxcena-neo-update.log"], { cwd: process.cwd(), detached : true, - stdio: "inherit" + stdio: "inherit", + shell: "/bin/bash" }); } -- cgit v1.2.3 From 01ee9242e4d1dd7de95b7eccc9658d7129a5cd41 Mon Sep 17 00:00:00 2001 From: Jakob Stendahl <14180120+JakobST1n@users.noreply.github.com> Date: Fri, 15 Oct 2021 12:53:10 +0200 Subject: :hammer: Manually add all paths --- bin/luxcena-neo-cli.sh | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/bin/luxcena-neo-cli.sh b/bin/luxcena-neo-cli.sh index 161293e..9157047 100755 --- a/bin/luxcena-neo-cli.sh +++ b/bin/luxcena-neo-cli.sh @@ -108,8 +108,15 @@ printf "\e[37mLuxcena-\e[31mn\e[32me\e[34mo\e[37m-cli \e[90m[args: '$*']\n\n\e[0 action=$1 if [ "$action" == "update" ]; then - - tput rev + PATH=/bin:$PATH + PATH=/sbin:$PATH + PATH=/usr/local/sbin:$PATH + PATH=/usr/local/bin:$PATH + PATH=/usr/sbin:$PATH + PATH=/usr/bin:$PATH + PATH=/usr/sbin:$PATH + + tput rev printf '%s\n' "Luxcena-neo Updater" tput sgr0 printf '\e[93m%s\e[0m\n' "-------------------" -- cgit v1.2.3 From 5133aa726c0d28e8cebd7fe2307e623fb9db2a51 Mon Sep 17 00:00:00 2001 From: Jakob Stendahl <14180120+JakobST1n@users.noreply.github.com> Date: Fri, 15 Oct 2021 14:29:37 +0200 Subject: :hammer: Attempt to make it look okay outside tty --- bin/luxcena-neo-cli.sh | 105 +++++++++++++++++++++++++++++-------------------- 1 file changed, 63 insertions(+), 42 deletions(-) diff --git a/bin/luxcena-neo-cli.sh b/bin/luxcena-neo-cli.sh index 9157047..7346b3a 100755 --- a/bin/luxcena-neo-cli.sh +++ b/bin/luxcena-neo-cli.sh @@ -5,64 +5,85 @@ usage() { exit 1 } +function TPUT() { + if [ -t 1 ]; then + shift + tput $@ + fi +} + function startLuxcenaNeo() { header "Start Luxcena NEO" execCommand "systemctl start luxcena-neo" 1 } function header() { - tput setaf 3 - printf "\n[ ] $1" - tput sgr0 + TPUT setaf 3 + if [ -t 1 ]; then + printf "\n[ ] $1" + else + printf "\n- $1" + fi + TPUT sgr0 } function commandError() { trap - 1 cat /tmp/luxcena-neo-update.log - tput setaf 1 + TPUT setaf 1 printf "\n\nInstall failed.\n" - tput sgr0 + TPUT sgr0 startLuxcenaNeo exit 1 } -function execCommand() { - tput sc - tput setaf 4 - printf " ($1)" - tput sgr0 - bash -c "$1 > /tmp/luxcena-neo-update.log 2>&1" & - - PID=$! - +function spinner() { i=1 sp="/-\|" - while ps a | awk '{print $1}' | grep -q "$PID"; do - tput cub $(tput cols) - tput cuf 1 + while ps a | awk '{print $1}' | grep -q "$1"; do + TPUT cub $(TPUT cols) + TPUT cuf 1 printf "${sp:i++%${#sp}:1}" - tput cuf $(tput cols) + TPUT cuf $(TPUT cols) sleep 0.09 done - tput cub $(tput cols) - tput cuf 1 + TPUT cub $(TPUT cols) + TPUT cuf 1 +} + +function execCommand() { + TPUT sc + TPUT setaf 4 + if [ -t 1 ]; then + printf " ($1)" + else + printf "\n>> $1 " + fi + TPUT sgr0 + bash -c "$1 > /tmp/luxcena-neo-update.log 2>&1" & + + PID=$! + + if [ -t 1 ]; then + spinner $PID + fi wait $PID commandSucc=$? if [ $commandSucc -eq 0 ]; then - tput setaf 2 + TPUT setaf 2 printf "✓" - tput sgr0 - tput rc - tput el + TPUT sgr0 + TPUT rc + TPUT el else - tput setaf 1 + TPUT setaf 1 printf "x" - tput sgr0 - tput cuf $(tput cols) + TPUT sgr0 + TPUT cuf $(TPUT cols) printf "\n" if [ $# -eq 1 ] || [ $2 -eq "0" ]; then commandError @@ -71,20 +92,20 @@ function execCommand() { } function dlgYN() { - tput sc - tput setaf 4 + TPUT sc + TPUT setaf 4 printf "$1 (y/n)? " while : do read -n 1 -p "" YNQuestionAnswer if [[ $YNQuestionAnswer == "y" ]]; then - tput rc; tput el + TPUT rc; TPUT el printf ". $1?: \e[0;32mYes\e[0m\n" - tput sc + TPUT sc eval $2=1 # Set parameter 2 of input to the return value break elif [[ $YNQuestionAnswer == "n" ]]; then - tput rc; tput el + TPUT rc; TPUT el printf ". $1?: \e[0;31mNo\e[0m\n" eval $2=0 # Set parameter 2 of input to the return value break @@ -116,9 +137,9 @@ if [ "$action" == "update" ]; then PATH=/usr/bin:$PATH PATH=/usr/sbin:$PATH - tput rev + TPUT rev printf '%s\n' "Luxcena-neo Updater" - tput sgr0 + TPUT sgr0 printf '\e[93m%s\e[0m\n' "-------------------" if [ "$EUID" -ne 0 ]; then @@ -138,7 +159,7 @@ if [ "$action" == "update" ]; then execCommand "git clone -b $repoBranch $repoUrl $UPDATEDIR" header "Create backup" - execCommand "mkdir -p /opt/luxcena-neo/backup" + execCommand "mkdir -p /var/luxcena-neo/backup" BACKUPDIR=$(mktemp -d -p /var/luxcena-neo/backup backup.XXXXXX) execCommand "cp -R /opt/luxcena-neo/ $BACKUPDIR" @@ -178,11 +199,11 @@ if [ "$action" == "update" ]; then exit 0 elif [ "$action" == "uninstall" ]; then - tput setab 1 + TPUT setab 1 printf '%s\n' "Luxcena Neo Uninstaller..." - tput sgr0 + TPUT sgr0 printf '\e[93m%s\e[0m' "--------------------------" - tput setaf 8 + TPUT setaf 8 printf "By uninstalling Luxcena-Neo you might loose all data, including your scripts.\n\n" dlgYN "Are you sure you want to uninstall?" res @@ -199,14 +220,14 @@ elif [ "$action" == "uninstall" ]; then execCommand "rm -f /usr/bin/luxcena-neo.sh" execCommand "rm -f /usr/bin/lux-neo" - tput setaf 2 + TPUT setaf 2 printf "\nEverything should now be gone.\n" printf "/etc/luxcena-neo and /var/log/luxcena-neo is not removed.\n" - tput sgr0 - tput setaf 8 + TPUT sgr0 + TPUT setaf 8 printf "Well, some dependencies still exists. Those are:\n" printf " - packages (nodejs python3 python3-pip)\n" - tput sgr0 + TPUT sgr0 fi elif [ "$action" == "start" ]; then -- cgit v1.2.3 From ccba95a102665c34ea8252f90683c76972a045e3 Mon Sep 17 00:00:00 2001 From: Jakob Stendahl <14180120+JakobST1n@users.noreply.github.com> Date: Fri, 15 Oct 2021 14:45:25 +0200 Subject: :pencil2: Fix typo --- NeoRuntime/Runtime/luxcena_neo/neo_behaviour.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/NeoRuntime/Runtime/luxcena_neo/neo_behaviour.py b/NeoRuntime/Runtime/luxcena_neo/neo_behaviour.py index 6ae58fe..2eef444 100644 --- a/NeoRuntime/Runtime/luxcena_neo/neo_behaviour.py +++ b/NeoRuntime/Runtime/luxcena_neo/neo_behaviour.py @@ -266,7 +266,7 @@ class BooleanVariable(Variable): except: print("Attempted to set {} to \"{}\", which is not a valid bool...".format(self.name, value)) -class Trigger(self): +class Trigger(Variable): def __init__(self, name: str, **kwargs): super().__init__(name, False, VariableType.TRIGGER, **kwargs) @@ -278,4 +278,4 @@ class Trigger(self): if value: value = False super(BooleanVariable, type(self)).value.fset(self, value) except: - print("Attempted to set {} to \"{}\", which is not a valid bool...".format(self.name, value)) \ No newline at end of file + print("Attempted to set {} to \"{}\", which is not a valid bool...".format(self.name, value)) -- cgit v1.2.3