Skip to content

Commit

Permalink
fix: Fix the install script
Browse files Browse the repository at this point in the history
  • Loading branch information
nadeesha committed Oct 25, 2021
1 parent b4724c4 commit ca6a3aa
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 29 deletions.
28 changes: 13 additions & 15 deletions install.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
ARCH="\$(uname -m)"
if [ "\$ARCH" == "x86_64" ]; then
ARCH=x64
ARCH=amd64
elif [[ "\$ARCH" == aarch* ]]; then
ARCH=arm
else
Expand All @@ -45,27 +45,25 @@
cd /usr/local/lib
rm -rf cloudstate
rm -rf ~/.local/share/cloudstate/client
if [ \$(command -v xz) ]; then
URL=https://cli-assets.cloudstate.com/cloudstate-\$OS-\$ARCH.tar.xz
TAR_ARGS="xJ"
else
URL=https://cli-assets.cloudstate.com/cloudstate-\$OS-\$ARCH.tar.gz
TAR_ARGS="xz"
fi
mkdir -p cloudstate/bin
cd cloudstate/bin
URL="https://github.com/usecloudstate/cli/releases/download/v1.0.1/cloudstate-cli-\$OS-\$ARCH"
echo "Installing CLI from \$URL"
if [ \$(command -v curl) ]; then
curl "\$URL" | tar "\$TAR_ARGS"
if [ \$(command -v curlf) ]; then
curl -L "\$URL" --output cli
else
wget -O- "\$URL" | tar "\$TAR_ARGS"
wget -O- "\$URL" > cli
fi
# delete old cloudstate bin if exists
rm -f \$(command -v cloudstate) || true
rm -f /usr/local/bin/cloudstate
ln -s /usr/local/lib/cloudstate/bin/cloudstate /usr/local/bin/cloudstate
ln -s /usr/local/lib/cloudstate/bin/cli /usr/local/bin/cloudstate
# on alpine (and maybe others) the basic node binary does not work
# remove our node binary and fall back to whatever node is on the PATH
/usr/local/lib/cloudstate/bin/node -v || rm /usr/local/lib/cloudstate/bin/node
chmod +x /usr/local/lib/cloudstate/bin/cli
SCRIPT
# test the CLI
Expand Down
18 changes: 4 additions & 14 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ package main
import (
"log"
"os"
"os/signal"
"syscall"

"github.com/usecloudstate/cli/pkg/apps"
"github.com/usecloudstate/cli/pkg/client"
Expand Down Expand Up @@ -80,18 +78,10 @@ func next(s State, ctx StateMachineCtx) {
}

func main() {
signalChannel := make(chan os.Signal, 2)
signal.Notify(signalChannel, os.Interrupt, syscall.SIGTERM)

go func() {
sig := <-signalChannel
switch sig {
case os.Interrupt:
case syscall.SIGTERM:
log.Println("Exiting...")
os.Exit(1)
}
}()
log.Println("=================================================================")
log.Println("🚀 Starting Cloudstate CLI")
log.Println("Please report any issues at: https://github.com/usecloudstate/cli")
log.Println("=================================================================")

ctx := StateMachineCtx{}
next(SInit, ctx)
Expand Down

0 comments on commit ca6a3aa

Please sign in to comment.