add branch ability

This commit is contained in:
Luke Smith 2019-05-18 16:44:25 -04:00
parent 3d6ceb918b
commit 6d5389c7d8
No known key found for this signature in database
GPG Key ID: 4C50B54A911F6252

View File

@ -5,9 +5,10 @@
### OPTIONS AND VARIABLES ###
while getopts ":a:r:p:h" o; do case "${o}" in
h) printf "Optional arguments for custom use:\\n -r: Dotfiles repository (local file or url)\\n -p: Dependencies and programs csv (local file or url)\\n -a: AUR helper (must have pacman-like syntax)\\n -h: Show this message\\n" && exit ;;
while getopts ":a:r:b:p:h" o; do case "${o}" in
h) printf "Optional arguments for custom use:\\n -r: Dotfiles repository (local file or url)\\n -b: Dotfiles branch (master is assumed otherwise)\\n -p: Dependencies and programs csv (local file or url)\\n -a: AUR helper (must have pacman-like syntax)\\n -h: Show this message\\n" && exit ;;
r) dotfilesrepo=${OPTARG} && git ls-remote "$dotfilesrepo" || exit ;;
b) repobranch=${OPTARG} ;;
p) progsfile=${OPTARG} ;;
a) aurhelper=${OPTARG} ;;
*) printf "Invalid option: -%s\\n" "$OPTARG" && exit ;;
@ -17,6 +18,7 @@ esac done
[ -z "$dotfilesrepo" ] && dotfilesrepo="https://github.com/lukesmithxyz/voidrice.git"
[ -z "$progsfile" ] && progsfile="https://raw.githubusercontent.com/LukeSmithxyz/LARBS/master/archi3/progs.csv"
[ -z "$aurhelper" ] && aurhelper="yay"
[ -z "$repobranch" ] && repobranch="master"
### FUNCTIONS ###
@ -120,10 +122,11 @@ installationloop() { \
putgitrepo() { # Downlods a gitrepo $1 and places the files in $2 only overwriting conflicts
dialog --infobox "Downloading and installing config files..." 4 60
[ -z "$repobranch" ] && branch="master" || branch="$repobranch"
dir=$(mktemp -d)
[ ! -d "$2" ] && mkdir -p "$2" && chown -R "$name:wheel" "$2"
chown -R "$name:wheel" "$dir"
sudo -u "$name" git clone --depth 1 "$1" "$dir/gitrepo" >/dev/null 2>&1 &&
sudo -u "$name" git clone -b "$branch" --depth 1 "$1" "$dir/gitrepo" >/dev/null 2>&1 &&
sudo -u "$name" cp -rfT "$dir/gitrepo" "$2"
}
@ -197,7 +200,7 @@ manualinstall $aurhelper || error "Failed to install AUR helper."
installationloop
# Install the dotfiles in the user's home directory
putgitrepo "$dotfilesrepo" "/home/$name"
putgitrepo "$dotfilesrepo" "/home/$name" "$repobranch"
rm -f "/home/$name/README.md" "/home/$name/LICENSE"
# Install the LARBS Firefox profile in ~/.mozilla/firefox/