2021-02-20 15:30:43 +01:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
2021-04-13 07:37:03 +02:00
|
|
|
echo "Dotfiles Bootstrap Script by Andrei Jiroh"
|
2021-02-20 15:30:43 +01:00
|
|
|
echo "Starting up in 3 seconds..."
|
|
|
|
sleep 3
|
|
|
|
|
2021-02-20 16:00:56 +01:00
|
|
|
echo "==> Checking for GitLab Auth tokens in env..."
|
2021-02-20 15:30:43 +01:00
|
|
|
|
2021-02-20 16:04:15 +01:00
|
|
|
if [[ $GH_PAT == "" ]] && [[ $GH_USERNAME == "" ]]; then
|
2021-02-22 14:17:52 +01:00
|
|
|
echo "⚠ GH_USERNAME and GH_PAT can't be blank!"
|
2021-02-20 16:00:56 +01:00
|
|
|
exit 1
|
2021-04-13 07:37:03 +02:00
|
|
|
# Probably change my GitLab SaaS username with yours
|
2021-02-20 16:00:56 +01:00
|
|
|
elif [[ $GH_USERNAME != "AndreiJirohHaliliDev2006" ]]; then
|
2021-02-22 14:17:52 +01:00
|
|
|
echo "⚠ Only Andrei Jiroh can do this!"
|
2021-02-20 16:00:56 +01:00
|
|
|
exit 1
|
2021-02-20 16:09:13 +01:00
|
|
|
elif [[ $GH_USERNAME == "AndreiJirohHaliliDev2006" ]] && [[ $GH_PAT == "" ]]; then
|
2021-02-22 14:17:52 +01:00
|
|
|
echo "⚠ Missing GitLab.com PAT!"
|
2021-02-20 16:00:56 +01:00
|
|
|
exit 1
|
2021-02-20 16:04:15 +01:00
|
|
|
else
|
2021-04-05 05:53:52 +02:00
|
|
|
echo "⚠ Proceeding, please don't expect this works if things go brrr..."
|
2021-02-20 16:00:56 +01:00
|
|
|
fi
|
2021-02-20 16:04:15 +01:00
|
|
|
|
2021-02-27 17:02:24 +01:00
|
|
|
if [[ $PWD != $HOME ]]; then
|
|
|
|
echo "This script only works if you're in the home directory"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2021-02-20 15:30:43 +01:00
|
|
|
if echo $OSTYPE | grep linux-android.*; then
|
2021-04-13 07:37:03 +02:00
|
|
|
# Assuming that you istalled either wget or curl
|
2021-02-20 15:30:43 +01:00
|
|
|
echo "==> Installing dependencies..."
|
2021-04-13 07:37:03 +02:00
|
|
|
pkg install -y man git nano gnupg openssh proot resolv-conf asciinema
|
|
|
|
echo "info: Essientials are installed, if you need Node.js"
|
|
|
|
echo "info: just do `pkg install nodejs` anytime"
|
2021-02-20 15:30:43 +01:00
|
|
|
|
|
|
|
# Clone our stuff
|
|
|
|
echo "==> Cloning the dotfiles repo"
|
2021-04-06 11:50:36 +02:00
|
|
|
git clone https://github.com/AndreiJirohHaliliDev2006/dotfiles.git
|
|
|
|
cd .dotfiles && git clone https://$GH_USERNAME:$GH_PAT@gitlab.com/AndreiJirohHaliliDev2006/dotfiles-secrets secrets
|
2021-02-20 15:30:43 +01:00
|
|
|
|
|
|
|
if [[ $? != 0 ]]; then
|
2021-04-13 07:37:03 +02:00
|
|
|
echo "❌ That kinda sus, but either only Andrei Jiroh can proceed"
|
|
|
|
echo " or maybe the PAT you used is invalid."
|
2021-02-20 15:30:43 +01:00
|
|
|
exit 1
|
2021-04-06 11:50:36 +02:00
|
|
|
else
|
|
|
|
chmod 700 $HOME/.dotfiles/secrets
|
2021-02-20 15:30:43 +01:00
|
|
|
fi
|
|
|
|
|
2021-04-05 05:48:37 +02:00
|
|
|
cd ~
|
|
|
|
|
2021-02-20 15:30:43 +01:00
|
|
|
# Importing our SSH keys
|
2021-02-27 17:02:24 +01:00
|
|
|
echo "==> Checking if ~/.ssh exists..."
|
|
|
|
mkdir ~/.ssh && echo "We made that directory for you." || echo "warning: ~/.ssh exists!"
|
|
|
|
echo "==> Copying SSH keys"
|
2021-04-05 05:48:37 +02:00
|
|
|
cp $HOME/.dotfiles/secrets/ssh/github-personal ~/.ssh/github-personal
|
|
|
|
cp $HOME/.dotfiles/secrets/ssh/github-personal.pub ~/.ssh/github-personal.pub
|
|
|
|
cp $HOME/.dotfiles/secrets/ssh/launchpad ~/.ssh/launchpad
|
|
|
|
cp $HOME/.dotfiles/secrets/ssh/launchpad.pub ~/.ssh/launchpad.pub
|
2021-02-27 17:02:24 +01:00
|
|
|
chmod 600 ~/.ssh/launchpad
|
|
|
|
chmod 600 ~/.ssh/github-personal
|
2021-04-04 17:19:52 +02:00
|
|
|
#echo "==> Generating OpenSSH client config..."
|
2021-04-05 05:53:52 +02:00
|
|
|
ln -s $HOME/.ssh/config $HOME/.dotfiles/ssh/termux
|
2021-02-20 15:30:43 +01:00
|
|
|
|
|
|
|
# Link softly
|
|
|
|
echo "==> Creating soft links for .bashrc and .gitconfig"
|
2021-04-13 07:40:13 +02:00
|
|
|
ln -s $HOME/.dotfiles/termux.bashrc ~/.bashrc
|
|
|
|
ln -s $HOME/.dotfiles/termux.gitconfig ~/.gitconfig
|
2021-02-20 15:30:43 +01:00
|
|
|
|
2021-04-13 07:40:13 +02:00
|
|
|
echo "✔ Task completed successfully."
|
|
|
|
echo '==> Cleaning up to ensure no secrets are leaked..."
|
|
|
|
history -c
|
|
|
|
unset GH_USERNAME GH_PAT
|
2021-04-05 05:53:52 +02:00
|
|
|
exit
|
2021-04-04 17:24:08 +02:00
|
|
|
#elif echo $OSTYPE | grep linux-gnu.* && ;then
|
2021-02-20 15:30:43 +01:00
|
|
|
else
|
2021-04-13 07:37:03 +02:00
|
|
|
echo "error: Script unsupported for this machine. See the online README for"
|
|
|
|
echo "error: guide on manual bootstrapping."
|
2021-02-20 15:30:43 +01:00
|
|
|
fi
|