#!/bin/bash

#Collection of funtions and aliases to automate the redundant tasks.

#First let's declare a few variables

update-DOTFiles() {  #This command takes the local copies and puts them into the git repo for updating 
	rsync  -rhHAX /home/ganome/.config/shellconfig/* /home/ganome/$company/repos/DOT-Files/gentoo/miniserver/home/user/.config/shellconfig/. ;
	rsync  -rhHAX /home/ganome/.bashrc /home/ganome/$company/repos/DOT-Files/gentoo/miniserver/home/user/.bashrc ;

	rsync -rhHAX /etc/portage/* $HOME/$company/repos/DOT-Files/gentoo/miniserver/etc/portage/. ;

	rsync -rhHAX /boot/config-$(uname -r) $HOME/$company/repos/DOT-Files/gentoo/miniserver/kernel/. ;

	rsync  -rhHAX --exclude="vivaldi" --exclude="quassel-irc.org" --exclude="google-chrome" --exclude="PCSX2" --exclude="transmission" --exclude="legendary" --exclude="Element" --exclude="balena-etcher-electron" --exclude="discord" --exclude="discord.bak" --exclude="heroic" --exclude="Slack" --exclude="Code" $HOME/.config/* $HOME/NewCompany/repos/DOT-Files/gentoo/miniserver/home/user/.config/. ;
	rsync -rhHAX $HOME/.*rc $HOME/$company/repos/DOT-Files/gentoo/miniserver/home/user/. ;

	cd /home/ganome/$company/repos/DOT-Files ;
	git pull ;
	git add . ;
	git commit -am "Automated updated process of shell scripts and DOT Files (miniserver)" ;
	git push ;
	cd - ;
}

replace-DOTFile() { #This command takes the git repo configs and moves them onto the local machine - in case remote edits were done and local machine needs updating
	rsync -rhHAX /home/ganome/$company/repos/DOT-Files/gentoo/miniserver/home/user/.bashrc /home/ganome/. ;
	rsync -rhHAX /home/ganome/$company/repos/DOT-Files/gentoo/miniserver/home/user/.config/shellconfig/* /home/ganome/.config/shellconfig/. ;
}

gitweb-start() {

	cd /var/lib/gitolite/repositories/DOT-Files.git ;
	sudo -u git git instaweb start ;
	echo "Starting the Git web service" ;
	cd - ;
}

gitweb-stop() {
	
	cd /var/lib/gitolite/repositories/DOT-Files.git ;
	sudo -u git git instaweb stop ;
	echo "Stopping the git-web service" ;
	cd - ;
}
