migrate/post-install

57 lines
1.5 KiB
Bash
Executable File

#!/usr/bin/env bash
# '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
gitDir="~/git"
[ ! -d $gitDir ] && mkdir -p $gitDir || echo $gitDir" already exists"
sshDir="~/.ssh"
[ ! -d $sshDir ] && mkdir -p $sshDir || echo $sshDir" already exists"
configDir="~/.config"
[ ! -d $configDir ] && mkdir -p $configDir || echo $configDir" already exists"
userBinDir="~/bin"
[ ! -d $userBinDir ] && mkdir -p $userBinDir || echo $userBindir" already exists"
# create an ssh key, for use with git/github
ssh-keygen -t ed25519 -f $sshDir"/id_ed25519_git" -N ''
# 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;
git clone https://github.com/crimsontome/config;
cp -f config/bin/* $userBinDir
cp -f config/ub-server/.bashrc ~/;
cp -f config/.gitconfig ~/;
cp -f config/.ssh/config $sshDir/config
elif [[ $os == "Fedora" ]]; then
echo "dnf is not yet supported";
exit
else
echo "OS not yet supported";
exit
fi
cd $gitdir
gh auth login
# after logged into gh
gh repo list --limit 100 |awk '{print $1}' | xargs -L1 gh repo clone