Skip to content

Instantly share code, notes, and snippets.

@vadim-a-yegorov
Forked from vadimszzz/exynex_preinstall.sh
Created March 17, 2023 04:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vadim-a-yegorov/70947e82193744b8a7235cfc2be5cd2d to your computer and use it in GitHub Desktop.
Save vadim-a-yegorov/70947e82193744b8a7235cfc2be5cd2d to your computer and use it in GitHub Desktop.
git submodule update --init --recursive
set -e
# Determine shell profile
try_profile() {
if [ -z "${1-}" ] || [ ! -f "${1}" ]; then
return 1
fi
echo "${1}"
}
SHELL_PROFILE=''
if [ "${SHELL#*bash}" != "$SHELL" ]; then
if [ -f "$HOME/.bashrc" ]; then
SHELL_PROFILE="$HOME/.bashrc"
elif [ -f "$HOME/.bash_profile" ]; then
SHELL_PROFILE="$HOME/.bash_profile"
fi
elif [ "${SHELL#*zsh}" != "$SHELL" ]; then
if [ -f "$HOME/.zshrc" ]; then
SHELL_PROFILE="$HOME/.zshrc"
fi
fi
if [ -z "$SHELL_PROFILE" ]; then
for EACH_PROFILE in ".profile" ".bashrc" ".bash_profile" ".zshrc"
do
if SHELL_PROFILE="$(try_profile "${HOME}/${EACH_PROFILE}")"; then
break
fi
done
fi
if [[ -z "$SHELL_PROFILE" ]]; then
echo $'Error: Your shell isn\'t supported. Please run: SHELL_PROFILE=$HOME/.yourshell_profile, then start the script again.'
exit 1;
fi
echo "[*] Shell profile: $SHELL_PROFILE"
source $SHELL_PROFILE
# Determine package manager
if [ "$(uname)" == "Darwin" ]; then
# Install brew
if [[ -z $(which brew) ]]; then
echo "[ ] Installing brew."
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" 1>/dev/null
fi
brew analytics off
PACKAGE_MANAGER=brew
elif [[ ! -z $(which yum) ]]; then
PACKAGE_MANAGER='sudo yum'; YES='-y'
elif [[ ! -z $(which apt-get) ]]; then
PACKAGE_MANAGER='sudo apt-get'; YES='-y'
elif [[ ! -z $(which apt) ]]; then
PACKAGE_MANAGER='sudo apt'; YES='-y'
elif [[ ! -z $(which apk) ]]; then
PACKAGE_MANAGER='sudo apk'; YES='-y'
else
echo $'[!] Error: Can\'t determine your package manager.'
exit 1;
fi
echo "[*] Package manager: $PACKAGE_MANAGER"
# Install pyenv
if [[ -z $(which pyenv) ]]; then
echo '[ ] Installing pyenv.'
curl -L https://github.com/pyenv/pyenv-installer/raw/master/bin/pyenv-installer | bash 1>/dev/null
fi
echo '[*] pyenv installed.'
if [[ $PATH == *"$HOME/.pyenv/bin"* ]]; then
echo $'[*] pyenv is already in your $PATH.'
else
echo '' >> $SHELL_PROFILE
echo '# Load pyenv - Python Version Manager' >> $SHELL_PROFILE
echo '# and pyenv-virtualenv' >> $SHELL_PROFILE
echo '' >> $SHELL_PROFILE
echo 'export PATH="$HOME/.pyenv/bin:$PATH"' >> $SHELL_PROFILE
echo 'eval "$(pyenv init --path)"' >> $SHELL_PROFILE
echo 'eval "$(pyenv virtualenv-init -)"' >> $SHELL_PROFILE
echo '' >> $SHELL_PROFILE
source $SHELL_PROFILE
echo $'[*] pyenv added to your $PATH.'
fi
pyenv install 3.9.0 -s 1>/dev/null
echo '[*] Python installed.'
pyenv global 3.9.0
# Install nvm - Node Version Manager
if [[ -z $NVM_DIR ]]; then
echo '[ ] Installing nvm.'
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/master/install.sh | bash
echo '' >> $SHELL_PROFILE
echo '# Load nvm - Node.js Version Manager' >> $SHELL_PROFILE
echo '' >> $SHELL_PROFILE
echo 'export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")"' >> $SHELL_PROFILE
echo '[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"' >> $SHELL_PROFILE
echo '[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"' >> $SHELL_PROFILE
echo '' >> $SHELL_PROFILE
source $SHELL_PROFILE
echo $'[*] nvm added to your $PATH.'
fi
echo '[*] nvm installed.'
nvm install --lts --no-progress 1>/dev/null
echo '[*] Node.js installed.'
nvm use --lts 1>/dev/null
# Install WireShark
if [[ -z $(which tshark) ]]; then
echo '[ ] Installing WireShark.'
eval "$PACKAGE_MANAGER update" 1>/dev/null
eval "$PACKAGE_MANAGER install wireshark $YES" 1>/dev/null
fi
echo '[*] WireShark installed.'
# Install Rust & Cargo
if [[ -z $(which cargo) ]]; then
echo '[ ] Installing Rust & Cargo.'
curl https://sh.rustup.rs -sSf | bash -s -- -y
fi
echo '[*] Rust & Cargo installed.'
pip install -r requirements.txt
echo '[*] Requirements installed.'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment