chore(cloudshell): update bootstrap to fix possible BS in Cloud Shell

Also did alot of munted shitshow in installing ShellCheck

Signed-off-by: Andrei Jiroh Eugenio Halili <andreijiroh@madebythepins.tk>
This commit is contained in:
Andrei Jiroh Eugenio Halili 2021-07-04 14:20:14 +00:00
parent 8afad5ee7f
commit a92c09df5d
Signed by: ajhalili2006
GPG Key ID: A30EBE40AD856D88
4 changed files with 56 additions and 19 deletions

View File

@ -1,6 +1,10 @@
#!/usr/bin/bash
#!/bin/bash
# update our cache stuff
apt-get update
# Install HashiCorp Vault, as usual. Don't forget to update GitHub CLI
apt install vault gh -y
# https://unix.stackexchange.com/questions/12702/no-manual-page-for-regex-in-section-3-where-is-it#12705
apt install manpages manpages-dev manpages-posix manpages-posix-dev -y

View File

@ -114,7 +114,8 @@ if ! shopt -oq posix; then
fi
# scripts in ~/.local/bin and ~/.dotfiles/bin
export DOTFILES_HOME="$HOME/.dotfiles" DOTFILES_STUFF_BIN="$DOTFILES_HOME/bin"
export DOTFILES_HOME="$HOME/.dotfiles"
export DOTFILES_STUFF_BIN="$DOTFILES_HOME/bin"
export PATH="$HOME/.local/bin:$DOTFILES_STUFF_BIN:$PATH"
# custom aliases and functions I made
@ -122,12 +123,20 @@ export PATH="$HOME/.local/bin:$DOTFILES_STUFF_BIN:$PATH"
source "$DOTFILES_HOME/bashrc/chain-source"
# TODO: Do checks if the GitHub CLI is installed later
#eval "$(gh completion -s bash)"
eval "$(gh completion -s bash)"
# https://packaging.ubuntu.com/html/getting-set-up.html#configure-your-shell
export DEBFULLNAME="Andrei Jiroh Halili"
## can't add this email to my Launchpad profile, probably because I'm using an free domain lol.
export DEBEMAIL="andreijiroh@madebythepins.tk"
# Summon our gpg-agent and ssh-agent
eval $(gpg-agent --daemon --enable-ssh-support)
# We still need this, just in case gpg-agent is being a dick
source $DOTFILES_STUFF_BIN/source-ssh-agent
export GPG_TTY=$(tty)
# After all of these, initialize Google's devshell bashrc
source /google/devshell/bashrc.google
if [ -f "/google/devshell/bashrc.google" ]; then
source "/google/devshell/bashrc.google"
fi

View File

@ -152,3 +152,7 @@ test -d /home/linuxbrew/.linuxbrew && eval "$(/home/linuxbrew/.linuxbrew/bin/bre
# Golang
export PATH=/home/gildedguy/go/bin:$PATH GOPATH=/home/gildedguy/go
if [ -f "/google/devshell/bashrc.google" ]; then
source "/google/devshell/bashrc.google"
fi

View File

@ -3,7 +3,9 @@
#set -e
# if undefined, use $HOME/.local
PREFIX=${PREFIX:$HOME/.local}
if [[ $PREFIX == "" ]]; then
export PREFIX=$HOME/.local/bin
fi
# TODO: Make this better
banner() {
@ -113,7 +115,7 @@ cloneRepo() {
git -C "$HOME/.dotfiles" fetch --all
git -C "$HOME/.dotfiles" pull origin
fi
slepp 5
sleep 5
if [[ $GITLAB_TOKEN == "" ]] && [[ $GITLAB_LOGIN == "" ]] && [ ! -d "$HOME/.dotfiles/secrets" ]; then
error "GitLab login and token can't be blank!" && exit 1
@ -128,9 +130,10 @@ cloneRepo() {
echoStageName "Cloning secrets repo"
git clone https://$GITLAB_LOGIN:$GITLAB_TOKEN@gitlab.com/ajhalili2006/dotfiles-secrets $HOME/.dotfiles/secrets
[ $? != "0" ] && echo "error: That kinda sus, but either only Andrei Jiroh can proceed or maybe the PAT you used is invalid." && exit 1
chmod 600 $HOME/.dotfiles/secrets/{ssh,pgp}
chmod 760 $HOME/.dotfiles/secrets
sleep 5
else
chmod 760 $HOME/.dotfiles/secrets
git -C "$HOME/.dotfiles/secrets" fetch --all
git -C "$HOME/.dotfiles/secrets" pull
sleep 5
@ -147,6 +150,7 @@ cleanup() {
pkg uninstall clang --yes && apt autoremove --yes
else
rm -rfv ~/{shellcheck,flarectl,LICENSE,README.txt,README.md} || true
unset PREFIX
fi
success "Setting up a new Linux machine was succesfully executed. To ensure no secrets are leaked when logging utfrom shell session, please do 'history -c' to cleanup shell history."
[ $GOOGLE_CLOUD_SHELL == "true" ] && warn "Looks like you're on Google Cloud Shell, please restart your virtual machine for changes to take effect."
@ -187,7 +191,7 @@ copyBashrc() {
ln -s "$HOME/.dotfiles/ubuntu.bashrc" ~/.bashrc
elif [[ $GOOGLE_CLOUD_SHELL == "true" ]] && [[ $SKIP_CONFIG_LINKING == "" ]] && [ -f "$HOME/.bashrc" ]; then
rm ~/.bashrc
ln -s "$HOME/.dotfiles/bashrc/googlecloudhsell.bashrc" ~/.bashrc
ln -s "$HOME/.dotfiles/bashrc/googlecloudshell.bashrc" ~/.bashrc
elif [[ $SKIP_CONFIG_LINKING == "" ]] && [ -f "$HOME/.bashrc" ]; then
warn "Existing bashrc found, renaming to ~/.bashrc.bak"
mv ~/.bashrc ~/.bashrc.bak
@ -202,8 +206,9 @@ copyGitConfig() {
[ ! -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
# See https://superuser.com/a/741610/1124908 for details
# By default, we'll use the one-size-fits-all Linux config for Git
elif [[ $DOTFILES_OS_NAME == "debian-ubuntu" ]] && [[ $SKIP_CONFIG_LINKING == "" ]]; then
[ ! -f "$HOME/.gitconfig" ] && ln -s $HOME/.dotfiles/linux/ubuntu ~/.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
}
@ -216,19 +221,32 @@ copyNanoConfig() {
installShellCheck() {
echoStageName "Installing Shellcheck"
scversion="stable" # or "v0.4.7", or "latest"
current_shellcheck_path=$(command -v shellcheck)
isOwnedByUser=$(find $PREFIX/bin -user $USER -file shellcheck)
wget -qO- "https://github.com/koalaman/shellcheck/releases/download/${scversion?}/shellcheck-${scversion?}.linux.x86_64.tar.xz" | tar -xJv
if [[ $current_shellcheck_path == "" ]]; then
cp "shellcheck-${scversion}/shellcheck" $PREFIX/bin
else
if [[ $SKIP_DEPENDENCY_INSTALL == "" ]]; then
scversion="stable" # or "v0.4.7", or "latest"
current_shellcheck_path=$(command -v shellcheck)
isOwnedByUser=$(find $PREFIX/bin -user $USER -file shellcheck)
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
if [[ $current_shellcheck_path == "" ]]; then
cp "shellcheck-${scversion}/shellcheck" $PREFIX/bin
elif [[ $current_shellcheck_path == "$PREFIX/bin/shellcheck" ]]; then
warn "Current ShellCheck install found in $PREFIX/bin, replacing with latest stable release..."
if [[ $isOwnedByUser == "" ]]; then
warn "Owned by either other user/root, summoning root"
sudo rm "${PREFIX}/bin/shellcheck"
else
rm "${PREFIX}/bin/shellcheck"
fi
cp "shellcheck-${scversion}/shellcheck" $PREFIX/bin
else
warn "Current ShellCheck install found in $current_shellcheck_bin, will be removed..."
if [[ $isOwnedByUser == "" ]]; then
sudo rm "${PREFIX}/bin/shellcheck"
else
rm "${PREFIX}/bin/shellcheck"
fi
cp "shellcheck-${scversion}/shellcheck" $PREFIX/bin
fi
fi
}
@ -273,8 +291,10 @@ installFilterRepo() {
# usage stuff
usage() {
echo "Accepted bootstrap script arguments are:"
echo "* --help|-d - Show this text."
echo "* --skip-dependency-install, -d - Skip installing dependencies"
echo "* --help|-h - Show this text."
echo "* -i - Skip installing different dependencies and packages"
echo "* -d - Enable debugging"
echo "* -l - Skip symlinking config files (nanorc, bashrc, etc.)"
}
customizeCloudShell() {
@ -284,7 +304,7 @@ customizeCloudShell() {
rm -fv ~/.customize_environment
fi
cp ~/.dotfiles/.config/devshell.env .customize_environment && chmod +x ~/.customize_environment
cp ~/.dotfiles/.config/devshell.env ~/.customize_environment && chmod +x ~/.customize_environment
}
main() {