From 19c5cd5e09ad71e78bc59ff20079a134818b02c6 Mon Sep 17 00:00:00 2001 From: sem Date: Mon, 5 Sep 2022 11:26:38 +0300 Subject: [PATCH] New Utils - installers --- .idea/.gitignore | 8 + .idea/Utils.iml | 8 + .idea/deployment.xml | 35 + .idea/modules.xml | 8 + .idea/vcs.xml | 6 + Installers/README.dm | 10 + Installers/docker.sh | 95 +++ Installers/golang.sh | 1837 ++++++++++++++++++++++++++++++++++++++++++ Installers/rust.sh | 1787 ++++++++++++++++++++++++++++++++++++++++ 9 files changed, 3794 insertions(+) create mode 100644 .idea/.gitignore create mode 100644 .idea/Utils.iml create mode 100644 .idea/deployment.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/vcs.xml create mode 100644 Installers/README.dm create mode 100644 Installers/docker.sh create mode 100644 Installers/golang.sh create mode 100644 Installers/rust.sh diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..13566b8 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/.idea/Utils.iml b/.idea/Utils.iml new file mode 100644 index 0000000..c956989 --- /dev/null +++ b/.idea/Utils.iml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/deployment.xml b/.idea/deployment.xml new file mode 100644 index 0000000..e159bed --- /dev/null +++ b/.idea/deployment.xml @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..9e64c4f --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Installers/README.dm b/Installers/README.dm new file mode 100644 index 0000000..a197d2c --- /dev/null +++ b/Installers/README.dm @@ -0,0 +1,10 @@ +Each script helps you to install compiler + +Example to use docker: +. <(wget -qO- https://raw.githubusercontent.com/letsnode/Utils/main/installers/docker.sh) + +go: +. <(wget -qO- https://raw.githubusercontent.com/letsnode/Utils/main/installers/golang.sh) + +rust: +. <(wget -qO- https://raw.githubusercontent.com/letsnode/Utils/main/installers/rust.sh) \ No newline at end of file diff --git a/Installers/docker.sh b/Installers/docker.sh new file mode 100644 index 0000000..d556fec --- /dev/null +++ b/Installers/docker.sh @@ -0,0 +1,95 @@ +#!/bin/bash + +dive="false" +action="install" + +. <(wget -qO- https://raw.githubusercontent.com/letsnode/Utils/main/bashbuilder/colors.sh) -- + +function option_value() { + echo "$1" | sed -e 's%^--[^=]*=%%g; s%^-[^=]*=%%g'; +} + +function install() { + cd + if ! docker --version; then + echo -e "${C_LGn}Docker installation...${RES}" + sudo apt update + sudo apt upgrade -y + sudo apt install curl apt-transport-https ca-certificates gnupg lsb-release -y + . /etc/*-release + wget -qO- "https://download.docker.com/linux/${DISTRIB_ID,,}/gpg" | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg + echo "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/${DISTRIB_ID,,} ${DISTRIB_CODENAME} stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null + sudo apt update + sudo apt install docker-ce docker-ce-cli containerd.io -y + docker_version=`apt-cache madison docker-ce | grep -oPm1 "(?<=docker-ce \| )([^_]+)(?= \| https)"` + sudo apt install docker-ce="$docker_version" docker-ce-cli="$docker_version" containerd.io -y + fi + if ! docker-compose --version; then + echo -e "${C_LGn}Docker Сompose installation...${RES}" + sudo apt update + sudo apt upgrade -y + sudo apt install wget jq -y + local docker_compose_version=`wget -qO- https://api.github.com/repos/docker/compose/releases/latest | jq -r ".tag_name"` + sudo wget -O /usr/bin/docker-compose "https://github.com/docker/compose/releases/download/${docker_compose_version}/docker-compose-`uname -s`-`uname -m`" + sudo chmod +x /usr/bin/docker-compose + . $HOME/.bash_profile + fi + if [ "$dive" = "true" ] && ! dpkg -s dive | grep -q "ok installed"; then + echo -e "${C_LGn}Dive installation...${RES}" + wget https://github.com/wagoodman/dive/releases/download/v0.9.2/dive_0.9.2_linux_amd64.deb + sudo apt install ./dive_0.9.2_linux_amd64.deb + rm -rf dive_0.9.2_linux_amd64.deb + fi +} + +function uninstall() { + echo -e "${C_LGn}Docker uninstalling...${RES}" + sudo dpkg -r dive + sudo systemctl stop docker.service docker.socket + sudo systemctl disable docker.service docker.socket + sudo rm -rf `systemctl cat docker.service | grep -oPm1 "(?<=^#)([^%]+)"` `systemctl cat docker.socket | grep -oPm1 "(?<=^#)([^%]+)"` /usr/bin/docker-compose + sudo apt purge docker-engine docker docker.io docker-ce docker-ce-cli -y + sudo apt autoremove --purge docker-engine docker docker.io docker-ce -y + sudo apt autoclean + sudo rm -rf /var/lib/docker /etc/appasudo rmor.d/docker + sudo groupdel docker + sudo rm -rf /etc/docker /usr/bin/docker /usr/libexec/docker /usr/libexec/docker/cli-plugins/docker-buildx /usr/libexec/docker/cli-plugins/docker-scan /usr/libexec/docker/cli-plugins/docker-app /usr/share/keyrings/docker-archive-keyring.gpg +} + +while test $# -gt 0; do + case "$1" in + -h|--help) + . <(wget -qO- https://raw.githubusercontent.com/letsnode/Utils/main/bashbuilder/logo.sh) + echo + echo -e "${C_LGn}Functionality${RES}: the script installs or uninstalls Docker" + echo + echo -e "${C_LGn}Usage${RES}: script ${C_LGn}[OPTIONS]${RES}" + echo + echo -e "${C_LGn}Options${RES}:" + echo -e " -h, --help show the help page" + echo -e " -d, --dive install Dive (images analyser)" + echo -e " -u, --uninstall uninstall Docker (${C_R}completely delete all images and containers${RES})" + echo + echo -e "${C_LGn}Useful URLs${RES}:" + echo -e "Script URL: https://raw.githubusercontent.com/letsnode/Utils/main/installers/docker.sh" + echo -e "Telegram community: https://t.me/letskynode — node Community" + echo + return 0 2>/dev/null; exit 0 + ;; + -d|--dive) + dive="true" + shift + ;; + -u|--uninstall) + action="uninstall" + shift + ;; + *|--) + break + ;; + esac +done + +$action + +echo -e "${C_LGn}Done!${RES}" diff --git a/Installers/golang.sh b/Installers/golang.sh new file mode 100644 index 0000000..e400af5 --- /dev/null +++ b/Installers/golang.sh @@ -0,0 +1,1837 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Utils/golang.sh at main · letsnode/Utils · GitHub + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ Skip to content + + + + + + + + + + + + +
+ +
+ + + + + + + +
+ + + + +
+ + + + + + + + + + + +
+
+
+ + + + + + + + + + + + + + + + + + +
+ + + + + + +
+ + +
+ + + + + + + + +Permalink + +
+ +
+
+ + + main + + + + +
+
+
+ Switch branches/tags + +
+ + + +
+ +
+ +
+ + +
+ +
+ + + + + + + + + + + + + + + +
+ + +
+
+
+
+ +
+ +
+ + + Go to file + +
+ + + + +
+
+
+ + + + + + + + + +
+ +
+
+
 
+
+ +
+
 
+ Cannot retrieve contributors at this time +
+
+ + + + + + + + + +
+ +
+ + +
+ + 77 lines (68 sloc) + + 2.24 KB +
+ +
+ + + + +
+ +
+
+
+
+ +
+
+
+
+
+ + + Open in GitHub Desktop +
+
+
+
+
+ + + +
+ + + + + + + + + +
+ + + +
+
+ +
+ +
+
+ + + +
+ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
#!/bin/bash
+
action="install"
go_version="1.18.1"
+
. <(wget -qO- https://raw.githubusercontent.com/letsnode/Utils/main/bashbuilder/colors.sh) --
+
function option_value() {
echo "$1" | sed -e 's%^--[^=]*=%%g; s%^-[^=]*=%%g';
}
+
function install() {
echo -e "${C_LGn}GO installation...${RES}"
if ! go version | grep -q $go_version; then
sed -i "s%:`which go | sed 's%/bin/go%%g'`%%g" $HOME/.bash_profile
rm -rf `which go | sed 's%/bin/go%%g'`
sudo apt update
sudo apt upgrade -y
sudo apt install tar wget git make -y
cd "$HOME"
wget -t 5 "https://go.dev/dl/go${go_version}.linux-amd64.tar.gz"
sudo rm -rf /usr/local/go
sudo tar -C /usr/local -xzf "go${go_version}.linux-amd64.tar.gz"
rm "go${go_version}.linux-amd64.tar.gz"
. <(wget -qO- https://raw.githubusercontent.com/letsnode/Utils/main/bashbuilder/addvar.sh) -n "PATH" -v "$PATH:/usr/local/go/bin:$HOME/go/bin"
fi
}
+
function uninstall() {
echo -e "${C_LGn}GO uninstalling...${RES}"
sed -i "s%:`which go | sed 's%/bin/go%%g'`%%g" "$HOME"/.bash_profile
rm -rf `which go | sed 's%/bin/go%%g'`
}
+
while test $# -gt 0; do
case "$1" in
-h|--help)
. <(wget -qO- https://raw.githubusercontent.com/letsnode/Utils/main/bashbuilder/logo.sh)
echo
echo -e "${C_LGn}Functionality${RES}: the script installs or uninstalls GO"
echo
echo -e "${C_LGn}Usage${RES}: script ${C_LGn}[OPTIONS]${RES}"
echo
echo -e "${C_LGn}Options${RES}:"
echo -e " -h, --help show the help page"
echo -e " -v, --version VERSION GO VERSION to install (default is ${C_LGn}${go_version}${RES})"
echo -e " -u, --uninstall uninstall GO"
echo
echo -e "You can use either \"=\" or \" \" as an option and value ${C_LGn}delimiter${RES}"
echo
echo -e "${C_LGn}Useful URLs${RES}:"
echo -e "https://raw.githubusercontent.com/letsnode/Utils/main/installers/golang.sh - script URL"
echo -e "https://t.me/letskynode — node Community"
echo -e "https://teletype.in/@letskynode — guides and articles"
echo
return 0 2>/dev/null; exit 0
;;
-v*|--version*)
if ! grep -q "=" <<< "$1"; then shift; fi
go_version=`option_value "$1"`
shift
;;
-u|--uninstall)
action="uninstall"
shift
;;
*|--)
break
;;
esac
done
+
$action
+
. "$HOME"/.bash_profile
+
echo -e "${C_LGn}Done!${RES}"
+
+ + + +
+ +
+ + + + +
+ + +
+ + +
+
+ + +
+ +
+ + +
+ +
+ + +
+
+ +
+ + + + + + + + + + + + + + + + + + + + + diff --git a/Installers/rust.sh b/Installers/rust.sh new file mode 100644 index 0000000..f46cee9 --- /dev/null +++ b/Installers/rust.sh @@ -0,0 +1,1787 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Utils/rust.sh at main · letsnode/Utils · GitHub + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ Skip to content + + + + + + + + + + + + +
+ +
+ + + + + + + +
+ + + + +
+ + + + + + + + + + + +
+
+
+ + + + + + + + + + + + + + + + + + +
+ + + + + + +
+ + +
+ + + + + + + + +Permalink + +
+ +
+
+ + + main + + + + +
+
+
+ Switch branches/tags + +
+ + + +
+ +
+ +
+ + +
+ +
+ + + + + + + + + + + + + + + +
+ + +
+
+
+
+ +
+ +
+ + + Go to file + +
+ + + + +
+
+
+ + + + + + + + + +
+ +
+
+
 
+
+ +
+
 
+ Cannot retrieve contributors at this time +
+
+ + + + + + + + + +
+ +
+ + +
+ + 66 lines (63 sloc) + + 1.78 KB +
+ +
+ + + + +
+ +
+
+
+
+ +
+
+
+
+
+ + + Open in GitHub Desktop +
+
+
+
+
+ + + +
+ + + + + + + + + +
+ + + +
+
+ +
+ +
+
+ + + +
+ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
#!/bin/bash
# Default variables
function="install"
nightly="false"
+
# Options
. <(wget -qO- https://raw.githubusercontent.com/letsnode/Utils/main/bashbuilder/colors.sh) --
option_value(){ echo "$1" | sed -e 's%^--[^=]*=%%g; s%^-[^=]*=%%g'; }
while test $# -gt 0; do
case "$1" in
-h|--help)
. <(wget -qO- https://raw.githubusercontent.com/letsnode/Utils/main/bashbuilder/logo.sh)
echo
echo -e "${C_LGn}Functionality${RES}: the script installs or uninstalls Rust"
echo
echo -e "${C_LGn}Usage${RES}: script ${C_LGn}[OPTIONS]${RES}"
echo
echo -e "${C_LGn}Options${RES}:"
echo -e " -h, --help show the help page"
echo -e " -n, --nightly install nightly version of Rust"
echo -e " -u, --uninstall uninstall Rust"
echo
echo -e "${C_LGn}Useful URLs${RES}:"
echo -e "Script URL: https://raw.githubusercontent.com/letsnode/Utils/main/installers/rust.sh"
echo -e "https://www.rust-lang.org/tools/install — Rust installation"
echo -e "https://t.me/letskynode — node Community"
echo -e "https://teletype.in/@letskynode — guides and articles"
echo
return 0 2>/dev/null; exit 0
;;
-n|--nightly)
nightly="true"
shift
;;
-u|--uninstall)
function="uninstall"
shift
;;
*|--)
break
;;
esac
done
+
# Functions
install() {
echo -e "${C_LGn}Rust installation...${RES}"
sudo apt update
sudo apt upgrade -y
sudo apt install curl build-essential pkg-config libssl-dev libudev-dev clang make -y
curl --proto '=https' -sSf https://sh.rustup.rs | sh -s -- -y
echo -e "${C_R}^ X Don't do that X ^${RES}\n"
. $HOME/.cargo/env
if [ "$nightly" = "true" ]; then
rustup toolchain install nightly
rustup default nightly
fi
}
uninstall() {
echo -e "${C_LGn}Rust uninstalling...${RES}"
rustup self uninstall -y
}
+
# Actions
$function
echo -e "${C_LGn}Done!${RES}"
+
+ + + +
+ +
+ + + + +
+ + +
+ + +
+
+ + +
+ +
+ + +
+ +
+ + +
+
+ +
+ + + + + + + + + + + + + + + + + + + + +