Compare commits

..

6 Commits

Author SHA1 Message Date
PorridgePi
37aeee9e40 bootstrap: zsh: feat: Add macOS support 2022-09-29 18:50:08 +08:00
PorridgePi
bd9897b343 bootstrap: gpg: feat: Add macOS support 2022-09-29 18:10:43 +08:00
PorridgePi
f69bbbf6be bootstrap: python3: feat: Add macOS support 2022-09-29 18:08:00 +08:00
PorridgePi
a21ba6a0ca zshenv: fix: Missing h from arch 2022-09-29 17:53:13 +08:00
PorridgePi
46c52068e2 bootstrap: librespeed-cli: refactor: Move aarch64 arm64 section out from Linux 2022-09-29 17:51:00 +08:00
PorridgePi
967e146480 bootstrap: librespeed-cli: feat: Add macOS support 2022-09-29 17:49:03 +08:00
5 changed files with 186 additions and 32 deletions

View File

@@ -1,7 +1,39 @@
if ! command -v gpg &> /dev/null; then if ! command -v gpg &> /dev/null; then
echo 'Installing gpg' echo 'Installing gpg'
sudo apt update
sudo apt install gpg -y source $HOME/.zshenv
if [[ "$OSNAME" == "Linux" ]]; then
# Linux
if [[ "$DISTRO_TYPE" == "debian" ]]; then
# Debian-based
sudo apt update
sudo apt install gpg -y
elif [[ "$DISTRO_TYPE" == "rpm" ]]; then
# RPM-based
echo 'ERROR: Currently unsupported'
echo 'Exiting...'
exit 1
elif [[ "$DISTRO_TYPE" == "arch" ]]; then
# Arch-based
echo 'ERROR: Currently unsupported'
echo 'Exiting...'
exit 1
else
# Unknown distro
echo 'ERROR: Unknown distro'
echo 'Exiting...'
exit 1
fi
elif [[ "$OSNAME" == "macOS" ]]; then
# macOS
brew install gpg
else
# Unknown
echo 'ERROR: Unknown OS'
echo 'Exiting...'
exit 1
fi
fi fi
echo 'gpg is installed' echo 'gpg is installed'

View File

@@ -2,29 +2,26 @@ if ! command -v librespeed-cli &> /dev/null; then
echo 'Installing librespeed-cli' echo 'Installing librespeed-cli'
source $HOME/.zshenv source $HOME/.zshenv
if [[ "$ARCH" == "aarch64" ]]; then
ARCH=arm64
fi
if [[ "$OSNAME" == "Linux" ]]; then if [[ "$OSNAME" == "Linux" ]]; then
# Linux # Linux
if [[ "$DISTRO_TYPE" == "debian" ]]; then URL=$(curl -fsSL https://api.github.com/repos/librespeed/speedtest-cli/releases/latest | grep browser_download_url | cut -d '"' -f 4 | grep linux | grep $ARCH)
# Debian-based mkdir -p $HOME/.temp/librespeed
if [[ "$ARCH" == "aarch64" ]]; then curl -fsSL -o $HOME/.temp/librespeed/librespeed.tar.gz "$URL"
ARCH=arm64 tar -xzf $HOME/.temp/librespeed/librespeed.tar.gz -C $HOME/.temp/librespeed/
fi cp $HOME/.temp/librespeed/librespeed-cli $HOME/bin/external/
URL=$(curl -fsSL https://api.github.com/repos/librespeed/speedtest-cli/releases/latest | grep browser_download_url | cut -d '"' -f 4 | grep linux | grep $ARCH) rm -r $HOME/.temp/librespeed/
mkdir -p $HOME/.temp/librespeed
curl -fsSL -o $HOME/.temp/librespeed/librespeed.tar.gz "$URL"
tar -xzf $HOME/.temp/librespeed/librespeed.tar.gz -C $HOME/.temp/librespeed/
cp $HOME/.temp/librespeed/librespeed-cli $HOME/bin/external/
rm -r $HOME/.temp/librespeed/
else
# Unknown distro
echo 'ERROR: Unknown distro'
echo 'Exiting...'
exit 1
fi
elif [[ "$OSNAME" == "macOS" ]]; then elif [[ "$OSNAME" == "macOS" ]]; then
# macOS # macOS
exit 1 URL=$(curl -fsSL https://api.github.com/repos/librespeed/speedtest-cli/releases/latest | grep browser_download_url | cut -d '"' -f 4 | grep darwin | grep $ARCH)
mkdir -p $HOME/.temp/librespeed
curl -fsSL -o $HOME/.temp/librespeed/librespeed.tar.gz "$URL"
tar -xzf $HOME/.temp/librespeed/librespeed.tar.gz -C $HOME/.temp/librespeed/
cp $HOME/.temp/librespeed/librespeed-cli $HOME/bin/external/
rm -r $HOME/.temp/librespeed/
else else
# Unknown # Unknown
echo 'ERROR: Unknown OS' echo 'ERROR: Unknown OS'

View File

@@ -1,15 +1,85 @@
if ! command -v python3 &> /dev/null; then if ! command -v python3 &> /dev/null; then
echo 'Installing python3' echo 'Installing python3'
sudo apt update
sudo apt install python3 -y source $HOME/.zshenv
if [[ "$OSNAME" == "Linux" ]]; then
# Linux
if [[ "$DISTRO_TYPE" == "debian" ]]; then
# Debian-based
sudo apt update
sudo apt install python3 -y
elif [[ "$DISTRO_TYPE" == "rpm" ]]; then
# RPM-based
echo 'ERROR: Currently unsupported'
echo 'Exiting...'
exit 1
elif [[ "$DISTRO_TYPE" == "arch" ]]; then
# Arch-based
echo 'ERROR: Currently unsupported'
echo 'Exiting...'
exit 1
else
# Unknown distro
echo 'ERROR: Unknown distro'
echo 'Exiting...'
exit 1
fi
elif [[ "$OSNAME" == "macOS" ]]; then
# macOS
brew install python3
else
# Unknown
echo 'ERROR: Unknown OS'
echo 'Exiting...'
exit 1
fi
fi fi
echo 'python3 is installed' echo 'python3 is installed'
if ! command -v pip3 &> /dev/null; then if ! command -v pip3 &> /dev/null; then
echo 'Installing pip3' echo 'Installing pip3'
sudo apt update
sudo apt install python3-pip -y source $HOME/.zshenv
if [[ "$OSNAME" == "Linux" ]]; then
# Linux
if [[ "$DISTRO_TYPE" == "debian" ]]; then
# Debian-based
sudo apt update
sudo apt install python3-pip -y
elif [[ "$DISTRO_TYPE" == "rpm" ]]; then
# RPM-based
echo 'ERROR: Currently unsupported'
echo 'Exiting...'
exit 1
elif [[ "$DISTRO_TYPE" == "arch" ]]; then
# Arch-based
echo 'ERROR: Currently unsupported'
echo 'Exiting...'
exit 1
else
# Unknown distro
echo 'ERROR: Unknown distro'
echo 'Exiting...'
exit 1
fi
elif [[ "$OSNAME" == "macOS" ]]; then
# macOS
echo 'ERROR: pip3 is not installed'
echo 'pip3 should have been installed by Homebrew together with python3.'
echo
echo 'Please re-run this script or manually re-install python3 with Homebrew.'
echo 'Exiting...'
exit 1
else
# Unknown
echo 'ERROR: Unknown OS'
echo 'Exiting...'
exit 1
fi
fi fi
echo 'pip3 is installed' echo 'pip3 is installed'

View File

@@ -1,17 +1,72 @@
#!/bin/bash source $HOME/.zshenv
if ! command -v zsh &> /dev/null; then if ! command -v zsh &> /dev/null; then
echo 'Installing zsh' echo 'Installing zsh'
sudo apt update
sudo apt install zsh -y if [[ "$OSNAME" == "Linux" ]]; then
# Linux
if [[ "$DISTRO_TYPE" == "debian" ]]; then
# Debian-based
sudo apt update
sudo apt install zsh -y
elif [[ "$DISTRO_TYPE" == "rpm" ]]; then
# RPM-based
echo 'ERROR: Currently unsupported'
echo 'Exiting...'
exit 1
elif [[ "$DISTRO_TYPE" == "arch" ]]; then
# Arch-based
echo 'ERROR: Currently unsupported'
echo 'Exiting...'
exit 1
else
# Unknown distro
echo 'ERROR: Unknown distro'
echo 'Exiting...'
exit 1
fi
elif [[ "$OSNAME" == "macOS" ]]; then
# macOS
brew install zsh
else
# Unknown
echo 'ERROR: Unknown OS'
echo 'Exiting...'
exit 1
fi
fi fi
echo 'zsh is installed' echo 'zsh is installed'
if [ ! $(awk -F: -v user="$USER" '$1 == user {print $NF}' /etc/passwd) = $(which zsh) ]; then
echo 'zsh is not default shell' if [[ "$OSNAME" == "Linux" ]]; then
echo 'Setting zsh as default shell...' # Linux
sudo chsh -s $(which zsh) $(whoami) if [ ! $(awk -F: -v user="$USER" '$1 == user {print $NF}' /etc/passwd) = $(which zsh) ]; then
echo 'zsh is not default shell'
echo 'Setting zsh as default shell...'
sudo chsh -s $(which zsh) $(whoami)
fi
elif [[ "$OSNAME" == "macOS" ]]; then
# macOS
if [[ "$SHELL" == "/bin/zsh" ]]; then
echo 'Homebrew zsh is not default shell'
if ! brew list zsh > /dev/null ; then
# Homebrew zsh not installed
echo 'Installing zsh from Homebrew'
brew install zsh
fi
echo 'Homebrew zsh installed'
echo 'Setting Homebrew zsh as default shell...'
grep -qxF "$(brew --prefix zsh)/bin/zsh" /etc/shells || sudo bash -c "echo $(brew --prefix zsh)/bin/zsh >> /etc/shells"
sudo chsh -s "$(brew --prefix zsh)/bin/zsh" $(whoami)
fi
else
# Unknown
echo 'ERROR: Unknown OS'
echo 'Exiting...'
exit 1
fi fi
echo 'zsh is default shell' echo 'zsh is default shell'

View File

@@ -31,7 +31,7 @@ if [[ "$OSTYPE" == "linux-gnu"* ]]; then
DISTRO_TYPE=rpm DISTRO_TYPE=rpm
elif command -v pacman &> /dev/null; then elif command -v pacman &> /dev/null; then
# Arch-based # Arch-based
DISTRO_TYPE=arc DISTRO_TYPE=arch
fi fi
elif [[ "$OSTYPE" == "darwin"* ]]; then elif [[ "$OSTYPE" == "darwin"* ]]; then
# macOS # macOS