-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
64 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|