Skip to content

Commit

Permalink
first version of scripts
Browse files Browse the repository at this point in the history
may not work for now, I will update soon
  • Loading branch information
mitucsaki committed Feb 27, 2018
1 parent b643064 commit 658b57c
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 0 deletions.
46 changes: 46 additions & 0 deletions install-go.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#!/bin/bash
set -e

golang="1.10"
download="go$golang.linux-armv6l.tar.gz"

check {
if [ "$EUID" -ne 0 ]; then
error "Error, please run as root"
exit 1
fi
}

echo "Checking if golang is already installed..."
if [ -d "$HOME/.go" ] || [ -d "$HOME/go" ]; then
echo "golang directories already exist. Exiting."
exit 1
fi

echo "Downloading golang version $golang"
cd
wget https://dl.google.com/go/go$golang.linux-armv6l.tar.gz /golang.tar.gz

if [ $? -ne 0 ]; then
echo "Download failed! Check script link and version."
exit 1
fi

echo "Installing..."
tar -C "$HOME" -xzf /golang.tar.gz
mv "$HOME/go" "$HOME/.go"
touch "$HOME/.$bashrc"
{
echo '# GoLang'
echo 'export GOROOT=$HOME/.go'
echo 'export PATH=$PATH:$GOROOT/bin'
echo 'export GOPATH=$HOME/go'
echo 'export PATH=$PATH:$GOPATH/bin'
} >> "$HOME/.$$bashrc"



mkdir -p $HOME/go/{src,pkg,bin}
echo -e "\nGolang $golang was installed.\nRe-initiate terminal to start variables"
rm -f golang.tar.gz

18 changes: 18 additions & 0 deletions uninstall-go.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash
set -e

check {
if [ "$EUID" -ne 0 ]; then
error "Error, please run as root"
exit 1
fi
}
rm -rf "$HOME/.go/"
sed -i '/# GoLang/d' "$HOME/.$bashrc"
sed -i '/export GOROOT/d' "$HOME/.$bashrc"
sed -i '/:$GOROOT/d' "$HOME/.$bashrc"
sed -i '/export GOPATH/d' "$HOME/.$bashrc"
sed -i '/:$GOPATH/d' "$HOME/.$bashrc"
echo "golang removed"
exit 0

0 comments on commit 658b57c

Please sign in to comment.