Created
July 28, 2022 17:42
-
-
Save perpen/22d4568985d1065752b3e715ca02246c to your computer and use it in GitHub Desktop.
Nothing interesting
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# To setup a new machine: | |
# - run $0 text on an existing machine | |
# - copy the output into the terminal of the target machine | |
set -euo pipefail | |
text() { | |
local string="$(tar cfj - \ | |
bin/setup-string \ | |
.secrets/id_rsa* \ | |
.ssh/id_rsa \ | |
.ssh/id_rsa.pub \ | |
| base64 -w 0)" | |
cat <<EOF | |
# Copy everything below this line into the target terminal | |
# Careful, the text contains secrets!!! | |
cd | |
echo "$string" | base64 -d | tar xvfj - | |
chmod -R go-rwx .secrets .ssh | |
export PATH=\$(pwd)/bin:\$PATH | |
setup-string init | |
# End | |
EOF | |
} | |
init() { | |
cd | |
rm -rf linux-home | |
sudo apt-get install -y git \ | |
|| sudo pacman -S --noconfirm --needed git | |
git clone [email protected]:perpen/linux-home.git | |
local old=$(date +%F_%T) | |
mkdir $old | |
mv \ | |
$(ls -a | grep -Ev '^(\.|\.\.|\.config|linux-home|bin|.secrets|.Xauthority)$') \ | |
$old | |
for overwritten in .config bin; do | |
cp -rf linux-home/$overwritten . | |
rm -rf linux-home/$overwritten | |
done | |
mv linux-home/.??* linux-home/* . | |
rm -rf linux-home | |
secrets decrypt | |
git status | |
ls -aF | |
read -rp "Run provision? (y/n) " | |
[[ "$REPLY" = y ]] && provision main | |
} | |
cd | |
"$@" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment