Update bootstrap script to improve Cloud Shell init process
Also don't forget to install shellcheck btw. Signed-off-by: Andrei Jiroh Eugenio Halili <andreijiroh@madebythepins.tk>
This commit is contained in:
parent
ac2bb9ef16
commit
f57e900c5d
94
bootstrap
94
bootstrap
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
# if undefined, use $HOME/.local
|
# if undefined, use $HOME/.local
|
||||||
if [[ $PREFIX == "" ]]; then
|
if [[ $PREFIX == "" ]]; then
|
||||||
export PREFIX=$HOME/.local/bin
|
export PREFIX=$HOME/.local
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# TODO: Make this better
|
# TODO: Make this better
|
||||||
|
@ -15,24 +15,13 @@ banner() {
|
||||||
}
|
}
|
||||||
|
|
||||||
useColor() {
|
useColor() {
|
||||||
# Only use colors if connected to a terminal
|
RED=$(printf '\033[31m')
|
||||||
if [ -t 1 ]; then
|
GREEN=$(printf '\033[32m')
|
||||||
RED=$(printf '\033[31m')
|
YELLOW=$(printf '\033[33m')
|
||||||
GREEN=$(printf '\033[32m')
|
BLUE=$(printf '\033[34m')
|
||||||
YELLOW=$(printf '\033[33m')
|
MAGENTA=$(printf '\033[35m')
|
||||||
BLUE=$(printf '\033[34m')
|
BOLD=$(printf '\033[1m')
|
||||||
MAGENTA=$(printf '\033[35m')
|
RESET=$(printf '\033[m')
|
||||||
BOLD=$(printf '\033[1m')
|
|
||||||
RESET=$(printf '\033[m')
|
|
||||||
else
|
|
||||||
RED=""
|
|
||||||
GREEN=""
|
|
||||||
YELLOW=""
|
|
||||||
BLUE=""
|
|
||||||
MAGENTA=""
|
|
||||||
BOLD=""
|
|
||||||
RESET=""
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
echoStageName() {
|
echoStageName() {
|
||||||
|
@ -98,11 +87,11 @@ installDeps() {
|
||||||
|
|
||||||
userspcaeBinDirCheck() {
|
userspcaeBinDirCheck() {
|
||||||
echoStageName "checking if PREFIX/bin exists"
|
echoStageName "checking if PREFIX/bin exists"
|
||||||
if [ ! -d $PREFIX/bin ]; then
|
if [ ! -d "$PREFIX/bin" ]; then
|
||||||
warn "$PREFIX/bin doesn't exists, creating..."
|
warn "$PREFIX/bin doesn't exists, creating..."
|
||||||
mkdir -p $PREFIX/bin
|
mkdir -p "$PREFIX/bin"
|
||||||
else
|
else
|
||||||
success "Looks good!"
|
success "Looks good! $PREFIX/bin directory exists."
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -145,7 +134,7 @@ cleanup() {
|
||||||
# just add chaos to these secrets to avoid leaks
|
# just add chaos to these secrets to avoid leaks
|
||||||
export GITLAB_LOGIN=gildedguy
|
export GITLAB_LOGIN=gildedguy
|
||||||
export GITLAB_TOKEN=build-guid-sus-among-computers-moment
|
export GITLAB_TOKEN=build-guid-sus-among-computers-moment
|
||||||
if echo $OSTYPE | grep -qE "linux-android.*"; then
|
if echo "$OSTYPE" | grep -qE "linux-android.*"; then
|
||||||
rm -rfv ~/{shellcheck,flarectl,LICENSE,README.txt,README.md}
|
rm -rfv ~/{shellcheck,flarectl,LICENSE,README.txt,README.md}
|
||||||
pkg uninstall clang --yes && apt autoremove --yes
|
pkg uninstall clang --yes && apt autoremove --yes
|
||||||
else
|
else
|
||||||
|
@ -162,14 +151,14 @@ cleanup() {
|
||||||
copyKeysSSH() {
|
copyKeysSSH() {
|
||||||
echoStageName "Copying SSH keys"
|
echoStageName "Copying SSH keys"
|
||||||
if [ ! -d "$HOME/.ssh" ]; then
|
if [ ! -d "$HOME/.ssh" ]; then
|
||||||
mkdir -p $HOME/.ssh
|
mkdir -p "$HOME/.ssh"
|
||||||
cp $HOME/.dotfiles/secrets/ssh/launchpad ~/.ssh/launchpad
|
cp "$HOME/.dotfiles/secrets/ssh/launchpad" "~/.ssh/launchpad"
|
||||||
cp $HOME/.dotfiles/secrets/ssh/launchpad.pub ~/.ssh/launchpad.pub
|
cp "$HOME/.dotfiles/secrets/ssh/launchpad.pub" "~/.ssh/launchpad.pub"
|
||||||
chmod 600 ~/.ssh/launchpad
|
chmod 600 "~/.ssh/launchpad"
|
||||||
else
|
else
|
||||||
cp $HOME/.dotfiles/secrets/ssh/launchpad ~/.ssh/launchpad
|
[ ! -f " ~/.ssh/launchpad" ] && cp "$HOME/.dotfiles/secrets/ssh/launchpad" "~/.ssh/launchpad"
|
||||||
cp $HOME/.dotfiles/secrets/ssh/launchpad.pub ~/.ssh/launchpad.pub
|
[ ! -f " ~/.ssh/launchpad.pub" ] && "cp $HOME/.dotfiles/secrets/ssh/launchpad.pub" "~/.ssh/launchpad.pub"
|
||||||
chmod 600 ~/.ssh/launchpad
|
chmod 600 "~/.ssh/launchpad"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echoStageName "Linking config files"
|
echoStageName "Linking config files"
|
||||||
|
@ -203,18 +192,18 @@ copyBashrc() {
|
||||||
copyGitConfig() {
|
copyGitConfig() {
|
||||||
echoStageName "Symlinking Git config"
|
echoStageName "Symlinking Git config"
|
||||||
if [[ $DOTFILES_OS_NAME == "android-termux" ]] && [[ $SKIP_CONFIG_LINKING == "" ]]; then
|
if [[ $DOTFILES_OS_NAME == "android-termux" ]] && [[ $SKIP_CONFIG_LINKING == "" ]]; then
|
||||||
[ ! -f "$HOME/.gitconfig" ] && ln -s $HOME/.dotfiles/gitconfig/termux ~/.gitconfig || warn "Git configuration on userspace found, please fix any conflicts or soft link them manually!"
|
[ ! -f "$HOME/.gitconfig" ] && ln -s "$HOME/.dotfiles/gitconfig/termux" ~/.gitconfig || warn "Git configuration on userspace found, please fix any conflicts or soft link them manually!"
|
||||||
# TODO: Write checks if it's Ubuntu or Debian
|
# TODO: Write checks if it's Ubuntu or Debian
|
||||||
# See https://superuser.com/a/741610/1124908 for details
|
# See https://superuser.com/a/741610/1124908 for details
|
||||||
# By default, we'll use the one-size-fits-all Linux config for Git
|
# By default, we'll use the one-size-fits-all Linux config for Git
|
||||||
elif [[ $DOTFILES_OS_NAME == "debian-ubuntu" ]] && [[ $SKIP_CONFIG_LINKING == "" ]]; then
|
elif [[ $DOTFILES_OS_NAME == "debian-ubuntu" ]] && [[ $SKIP_CONFIG_LINKING == "" ]]; then
|
||||||
[ ! -f "$HOME/.gitconfig" ] && ln -s $HOME/.dotfiles/gitconfig/linux ~/.gitconfig || warn "Git configuration on userspace found, please fix any conflicts or soft link them manually!"
|
[ ! -f "$HOME/.gitconfig" ] && ln -s "$HOME/.dotfiles/gitconfig/linux ~/.gitconfig" || warn "Git configuration on userspace found, please fix any conflicts or soft link them manually!"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
copyNanoConfig() {
|
copyNanoConfig() {
|
||||||
if [[ $DOTFILES_OS_NAME == "android-termux" ]]; then
|
if [[ $DOTFILES_OS_NAME == "android-termux" ]]; then
|
||||||
[ "$SKIP_CONFIG_LINKING" == "" ] && ln -s $HOME/.dotfiles/nanorc/config/termux $HOME/.nanorc
|
[ "$SKIP_CONFIG_LINKING" == "" ] && ln -s "$HOME/.dotfiles/nanorc/config/termux" "$HOME/.nanorc"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -226,9 +215,9 @@ installShellCheck() {
|
||||||
current_shellcheck_path=$(command -v shellcheck)
|
current_shellcheck_path=$(command -v shellcheck)
|
||||||
isOwnedByUser=$(find $PREFIX/bin -user $USER -file shellcheck)
|
isOwnedByUser=$(find $PREFIX/bin -user $USER -file shellcheck)
|
||||||
current_path_dir=$(dirname $current_shellcheck_path)
|
current_path_dir=$(dirname $current_shellcheck_path)
|
||||||
wget -qO- "https://github.com/koalaman/shellcheck/releases/download/${scversion?}/shellcheck-${scversion?}.linux.x86_64.tar.xz" | tar -xJv
|
wget -qO- "https://github.com/koalaman/shellcheck/releases/download/${scversion?}/shellcheck-${scversion?}.linux.x86_64.tar.xz" | tar -xJv -C "$HOME"
|
||||||
if [[ $current_shellcheck_path == "" ]]; then
|
if [[ $current_shellcheck_path == "" ]]; then
|
||||||
cp "shellcheck-${scversion}/shellcheck" $PREFIX/bin
|
cp "shellcheck-${scversion}/shellcheck" "$PREFIX/bin"
|
||||||
elif [[ $current_shellcheck_path == "$PREFIX/bin/shellcheck" ]]; then
|
elif [[ $current_shellcheck_path == "$PREFIX/bin/shellcheck" ]]; then
|
||||||
warn "Current ShellCheck install found in $PREFIX/bin, replacing with latest stable release..."
|
warn "Current ShellCheck install found in $PREFIX/bin, replacing with latest stable release..."
|
||||||
if [[ $isOwnedByUser == "" ]]; then
|
if [[ $isOwnedByUser == "" ]]; then
|
||||||
|
@ -237,34 +226,30 @@ installShellCheck() {
|
||||||
else
|
else
|
||||||
rm "${PREFIX}/bin/shellcheck"
|
rm "${PREFIX}/bin/shellcheck"
|
||||||
fi
|
fi
|
||||||
cp "shellcheck-${scversion}/shellcheck" $PREFIX/bin
|
cp "shellcheck-${scversion}/shellcheck" "$PREFIX/bin"
|
||||||
else
|
else
|
||||||
warn "Current ShellCheck install found in $current_shellcheck_bin, will be removed..."
|
warn "Current ShellCheck install found in $current_path_dir, will be removed..."
|
||||||
if [[ $isOwnedByUser == "" ]]; then
|
if [[ $isOwnedByUser == "" ]]; then
|
||||||
sudo rm "${PREFIX}/bin/shellcheck"
|
sudo rm "${PREFIX}/bin/shellcheck"
|
||||||
else
|
else
|
||||||
rm "${PREFIX}/bin/shellcheck"
|
rm "${PREFIX}/bin/shellcheck"
|
||||||
fi
|
fi
|
||||||
cp "shellcheck-${scversion}/shellcheck" $PREFIX/bin
|
cp "shellcheck-${scversion}/shellcheck" "$PREFIX/bin"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
installAscinema() {
|
installAscinema() {
|
||||||
if command -v python3 | grep -qE '^/usr/bin.*'; then
|
echoStageName "Installing Asciinema"
|
||||||
sudo "$(which python3)" -m pip install asciinema --upgrade
|
if [[ $DOTFILES_OS_NAME == "android-termux" ]] && [[ $SKIP_DEPENDENCY_INSTALL == "" ]] && [[ $USE_PIP3 == "" ]]; then
|
||||||
elif command -v python3>>/dev/null && [ -f "$HOME/.pyenv/shims/python3" ]; then
|
pkg install aciinema -y
|
||||||
$(which python3) -m pip install asciinema --upgrade
|
elif [[ $SKIP_DEPENDENCY_INSTALL == "" ]] && [[ $USE_PIP3 != "" ]]; then
|
||||||
else
|
pip3 install asciinema --user --upgrade
|
||||||
if [[ $DOTFILES_OS_NAME == "android-termux" ]]; then
|
|
||||||
pkg install asciinema --yes
|
|
||||||
else
|
|
||||||
sudo apt install asciinema --yes
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
installTF() {
|
installTF() {
|
||||||
|
echoStageName "Installing pip3:thefuck"
|
||||||
if [[ $DOTFILES_OS_NAME == "android-termux" ]]; then
|
if [[ $DOTFILES_OS_NAME == "android-termux" ]]; then
|
||||||
pkg install clang -y && pip install thefuck --user --upgrade
|
pkg install clang -y && pip install thefuck --user --upgrade
|
||||||
else
|
else
|
||||||
|
@ -277,8 +262,9 @@ installTF() {
|
||||||
}
|
}
|
||||||
|
|
||||||
installFilterRepo() {
|
installFilterRepo() {
|
||||||
|
echoStageName "Installing git-filter-repo"
|
||||||
if [[ $DOTFILES_OS_NAME == "android-termux" ]]; then
|
if [[ $DOTFILES_OS_NAME == "android-termux" ]]; then
|
||||||
pip install git-filter-repo
|
pip install git-filter-repo --upgrade
|
||||||
else
|
else
|
||||||
if command -v python3>>/dev/null && [ -f "$HOME/.pyenv/shims/python3" ]; then
|
if command -v python3>>/dev/null && [ -f "$HOME/.pyenv/shims/python3" ]; then
|
||||||
pip3 install git-filter-repo --upgrade
|
pip3 install git-filter-repo --upgrade
|
||||||
|
@ -305,6 +291,15 @@ customizeCloudShell() {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
cp ~/.dotfiles/.config/devshell.env ~/.customize_environment && chmod +x ~/.customize_environment
|
cp ~/.dotfiles/.config/devshell.env ~/.customize_environment && chmod +x ~/.customize_environment
|
||||||
|
if [ ! -d "$HOME/.cloudshell" ]; then
|
||||||
|
mkdir ~/.cloudshell
|
||||||
|
fi
|
||||||
|
if [ ! -f "$HOME/.cloudshell/no-apt-get-warning" ]; then
|
||||||
|
touch ~/.cloudshell/no-apt-get-warning
|
||||||
|
fi
|
||||||
|
|
||||||
|
echoStageName "Running ~/.customize_environment for you"
|
||||||
|
sudo $HOME/.customize_environment
|
||||||
}
|
}
|
||||||
|
|
||||||
main() {
|
main() {
|
||||||
|
@ -345,6 +340,7 @@ main() {
|
||||||
installAscinema
|
installAscinema
|
||||||
installTF
|
installTF
|
||||||
installFilterRepo
|
installFilterRepo
|
||||||
|
installShellCheck
|
||||||
|
|
||||||
# step 5: copy and symlink files
|
# step 5: copy and symlink files
|
||||||
copyGitConfig
|
copyGitConfig
|
||||||
|
|
Loading…
Reference in New Issue