114 lines
3.6 KiB
Bash
Executable File
114 lines
3.6 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
set -e
|
|
RAW_URL="https://sirherobrine23.org/Sirherobrine23/dotfiles/raw/branch/main"
|
|
USEGETER="curl"
|
|
SYSTEM="linux"
|
|
if [[ -z "${TMPDIR}" ]];then
|
|
export TMPDIR="/tmp"
|
|
fi
|
|
|
|
if command -v wget &> /dev/null;then
|
|
USEGETER="wget"
|
|
fi
|
|
|
|
if [[ `uname -s` == "Darwin" ]];then
|
|
SYSTEM="macos"
|
|
elif echo $HOME | grep -q "/data/data/com.termux";then
|
|
SYSTEM="android"
|
|
fi
|
|
|
|
function installPackages() {
|
|
if [[ "${SYSTEM}" == "macos" ]];then
|
|
if ! command -v brew &> /dev/null; then
|
|
download "https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh" "${TMPDIR}/brew.sh"
|
|
bash "${TMPDIR}/brew.sh"
|
|
rm "${TMPDIR}/brew.sh"
|
|
fi
|
|
brew install "${@:1}"
|
|
elif [[ "${SYSTEM}" == "android" ]];then
|
|
apt update
|
|
apt dist-upgrade -y
|
|
apt install -y "${@:1}"
|
|
else
|
|
if command -v dnf &> /dev/null; then
|
|
sudo dnf install -y "${@:1}"
|
|
else
|
|
sudo apt install -y "${@:1}"
|
|
fi
|
|
fi
|
|
return $?
|
|
}
|
|
|
|
function download() {
|
|
if [[ "${USEGETER}" == "wget" ]]; then
|
|
wget -q "${1}" -O "${2}"
|
|
else
|
|
curl -Ssl "${1}" > "${2}"
|
|
fi
|
|
return $?
|
|
}
|
|
|
|
function copyFile() {
|
|
if [[ -f "./${1}" ]]; then
|
|
cp -fv "./${1}" "${2}"
|
|
else
|
|
download "${RAW_URL}/${1}" "${2}"
|
|
fi
|
|
return 0
|
|
}
|
|
|
|
PKGS=(
|
|
gpg
|
|
htop
|
|
wget
|
|
jq
|
|
neovim
|
|
)
|
|
if [[ "${SYSTEM}" == "macos" ]];then
|
|
PKGS+=(gh gnupg pinentry-mac jq hyperkit minikube docker docker-buildx docker-compose golang)
|
|
mkdir ~/.gnupg
|
|
echo "pinentry-program $(brew --prefix)/bin/pinentry-mac" > ~/.gnupg/gpg-agent.conf
|
|
elif [[ "${SYSTEM}" == "android" ]];then
|
|
PKGS+=(zsh nodejs git gnupg gh golang wget curl jq clang make htop unzip zip tsu)
|
|
else
|
|
[[ -f "/etc/os-release" ]] && source /etc/os-release
|
|
if [[ "$(uname -m)" == "x86_64" ]] || [[ "$(uname -m)" == "aarch64" ]] || [[ "$(uname -m)" == "arm64" ]] || [[ "$(uname -m)" == "arm" ]]; then
|
|
installPackages wget curl jq
|
|
[[ -z "${NODE_MAJOR}" ]] && NODE_MAJOR=$(curl -Ssl https://nodejs.org/download/release/index.json | jq -r '.[0].version' | sed -nre 's/^[^0-9]*(([0-9]+)*[0-9]+).*/\1/p')
|
|
if [[ "$ID_LIKE" == "debian" ]] || [[ "$ID" == "debian" ]] || [[ "$ID" == "ubuntu" ]]; then
|
|
curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | sudo gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg
|
|
echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_$NODE_MAJOR.x nodistro main" | sudo tee /etc/apt/sources.list.d/nodesource.list
|
|
PKGS+=(nodejs)
|
|
else
|
|
SYS_ARCH=$(uname -m)
|
|
(
|
|
echo # Repository content for Node.js
|
|
echo "[nodesource-nodejs]"
|
|
echo "name=Node.js Packages for Linux RPM based distros - $SYS_ARCH"
|
|
echo "baseurl=https://rpm.nodesource.com/pub_${NODE_MAJOR}.x/nodistro/nodejs/$SYS_ARCH"
|
|
echo "priority=9"
|
|
echo "enabled=1"
|
|
echo "gpgcheck=1"
|
|
echo "gpgkey=https://rpm.nodesource.com/gpgkey/ns-operations-public.key"
|
|
echo "module_hotfixes=1"
|
|
) | sudo tee /etc/yum.repos.d/nodesource-nodejs.repo > /dev/null
|
|
sudo dnf makecache --disablerepo="*" --enablerepo="nodesource-nodejs"
|
|
PKGS+=(nodejs)
|
|
fi
|
|
fi
|
|
PKGS+=(git zsh curl jq clang make htop unzip zip)
|
|
fi
|
|
|
|
installPackages "${PKGS[@]}"
|
|
|
|
alias chsh=""
|
|
yes | sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
|
|
|
|
if [[ ! -d "$HOME/.oh-my-zsh/custom/plugins/zsh-autosuggestions" ]];then
|
|
git clone https://github.com/zsh-users/zsh-autosuggestions $HOME/.oh-my-zsh/custom/plugins/zsh-autosuggestions
|
|
fi
|
|
|
|
copyFile "bira+.zsh-theme" "$HOME/.oh-my-zsh/custom/themes/bira+.zsh-theme"
|
|
copyFile .zshrc "$HOME/.zshrc"
|
|
copyFile .gitconfig "$HOME/.gitconfig"
|