migrate/post-install

78 lines
2.3 KiB
Bash
Executable File

#!/usr/bin/env bash
# TODO fix so it loops through all pages, as it just grabs the first currently
# curl -s https://github.com/stars/CrimsonTome/lists/my-stack | docker run -i jezzay/html-xml-utils hxnormalize -x |docker run -i jezzay/html-xml-utils hxselect -c '#user-list-repositories > div > div > h3' | sed -n 's/.*href="\([^"]*\).*/\1/p' | awk '{print "https://github.com"$0}'|xargs -L1 git clone
# 'system migration' script designed to be ran once an os installed.
# set some variables
hostname=$HOSTNAME
echo $hostname
os=$(lsb_release -d| awk '{print $2}') # definitely works on Fedora
echo $os
# ensure some directories exist
mkdir -p ~/git/
mkdir -p ~/.ssh/
mkdir -p ~/.config/
mkdir -p ~/bin/
# create an ssh key, for use with git/github
ssh-keygen -t ed25519 -f "/home/`whoami`/.ssh/id_ed25519_git" -N ''
setup_config()
{
cd ~
git clone https://github.com/crimsontome/config;
cp -f config/bin/* ~/bin;
if [[ $os == "Ubuntu" ]]; then
cp -f config/ub-server/.bashrc ~/;
elif [[ $os == "Fedora" ]]; then
cp -f config/fedora/.bashrc ~/;
elif [[ $os == "Arch" ]]; then
cp -f config/arch/.bashrc ~/;
else
echo "OS specific bashrc not yet supported";
exit;
fi
cp -f config/.gitconfig ~/;
cp -f config/.ssh/config .ssh/config
}
# check package manager
if [[ $os == "Ubuntu" ]]; then
echo "using apt package manager";
sudo apt-get update && sudo apt-get upgrade;
sudo apt install -y `cat apt-packages`;
cat snap-packages| xargs -n 1 sudo snap install --classic;
wget https://dl.discordapp.net/apps/linux/0.0.21/discord-0.0.21.deb;
sudo apt install ./discord-0.0.21.deb;
setup_config $os;
elif [[ $os == "Fedora" ]]; then
echo "dnf is not yet supported";
setup_config $os;
elif [[ $os == "Arch" ]]; then
echo "pacman is not yet supported";
setup_config $os;
else
echo "OS package manager is not yet supported";
fi
cd ~/git/;
pwd
gh auth login;
# after logged into gh
#TODO: do gpg stuff toO
# gpg --export --armor KEY > pubkey.asc && gpg --export-secret-keys --armor KEY > privatekey.asc
# scp them to machine ~/keys
[ ! -d ~/keys ] && echo "No keys found" || gpg --import keys/*
gh repo list --limit 100 |awk '{print $1}' | xargs -L1 gh repo clone;