Merge all scripts into one which sucks a bit less
This commit is contained in:
parent
bc58e5b019
commit
1f8ad70893
13
bootstrap.sh
13
bootstrap.sh
@ -1,13 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
git clone http://adamgoldsmith.name/cgit/bootstrap.git .dotfiles
|
||||
cd .dotfiles
|
||||
git remote set-url origin http://adamgoldsmith.name/cgit/bootstrap.git
|
||||
git remote set-url --push origin ssh://adamgoldsmith.name:443/srv/git/bootstrap.git
|
||||
|
||||
targets="$@"
|
||||
if [ -n "$targets" ]
|
||||
then
|
||||
./getter.sh "$@"
|
||||
./stower.sh "$@"
|
||||
fi
|
109
getter.sh
109
getter.sh
@ -1,29 +1,102 @@
|
||||
#!/bin/bash
|
||||
|
||||
stow=0
|
||||
if [ "$1" = "-s" ]
|
||||
then
|
||||
stow=1
|
||||
shift
|
||||
fi
|
||||
set -eu
|
||||
|
||||
targets="$@"
|
||||
for t in $targets
|
||||
do
|
||||
if [ -d "$t" ]
|
||||
PULL_BASE="https://adamgoldsmith.name/cgit"
|
||||
PUSH_BASE="ag:/srv/git"
|
||||
|
||||
function do_get() {
|
||||
target="$1"
|
||||
if [ -d "$target" ]
|
||||
then
|
||||
echo "$t already exists, not getting"
|
||||
echo "$target already exists, not getting"
|
||||
else
|
||||
echo "Getting $t"
|
||||
git clone "http://adamgoldsmith.name/cgit/dotfiles/$t.git" --recurse-submodules
|
||||
cd $t
|
||||
git remote set-url origin http://adamgoldsmith.name/cgit/dotfiles/$t.git
|
||||
git remote set-url --push origin ag:/srv/git/dotfiles/$t.git
|
||||
echo "Getting $target"
|
||||
git clone "$PULL_BASE/dotfiles/$target.git" --recurse-submodules
|
||||
cd $target
|
||||
git remote set-url origin "$PULL_BASE/dotfiles/$target.git"
|
||||
git remote set-url --push origin "$PUSH_BASE/dotfiles/$target.git"
|
||||
cd ..
|
||||
fi
|
||||
}
|
||||
|
||||
function run_script() {
|
||||
script="$1"; shift
|
||||
targets="$@"
|
||||
for target in $targets
|
||||
do
|
||||
if [ -e "$target/$script" ]
|
||||
then
|
||||
echo "Running $target/$script"
|
||||
"$target/$script"
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
function maybe_stow() {
|
||||
targets="$@"
|
||||
if [ "$stow" = true ]
|
||||
then
|
||||
run_script PRESTOW "$targets"
|
||||
stow -t"$HOME" --ignore="^PRESTOW$" --ignore="^POSTSTOW$" $targets
|
||||
run_script POSTSTOW "$targets"
|
||||
fi
|
||||
}
|
||||
|
||||
stow=true
|
||||
bootstrap=false
|
||||
while [ "$#" -gt 0 ]
|
||||
do
|
||||
case $1 in
|
||||
-ns | --no-stow)
|
||||
stow=false
|
||||
shift
|
||||
;;
|
||||
-bs | --bootstrap)
|
||||
bootstrap=true
|
||||
shift
|
||||
;;
|
||||
--)
|
||||
shift
|
||||
break
|
||||
;;
|
||||
-?*)
|
||||
echo "Usage: $0 [-ns|--no-stow] [-bs|bootstrap] [<targets>]"
|
||||
exit 1
|
||||
;;
|
||||
*)
|
||||
break
|
||||
esac
|
||||
done
|
||||
|
||||
if [ "$stow" -eq 1 ]
|
||||
if [ "$bootstrap" = true ]
|
||||
then
|
||||
./stower.sh "$@"
|
||||
git clone "$PULL_BASE/bootstrap.git" .dotfiles
|
||||
cd .dotfiles
|
||||
git remote set-url origin "$PULL_BASE/bootstrap.git"
|
||||
git remote set-url --push origin "PUSH_BASE/bootstrap.git"
|
||||
fi
|
||||
|
||||
if [ "$#" -gt 0 ]
|
||||
then
|
||||
targets="$@"
|
||||
for target in $targets
|
||||
do
|
||||
do_get "$target"
|
||||
done
|
||||
maybe_stow "$targets"
|
||||
elif [ "$bootstrap" != true ]
|
||||
then
|
||||
echo "Updating .dotfiles"
|
||||
git pull
|
||||
|
||||
for dir in */
|
||||
do
|
||||
echo "Updating $dir"
|
||||
cd "$dir"
|
||||
git pull
|
||||
cd ..
|
||||
done
|
||||
|
||||
maybe_stow "*/"
|
||||
fi
|
||||
|
26
stower.sh
26
stower.sh
@ -1,26 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
targets="$@"
|
||||
for t in $targets
|
||||
do
|
||||
if [ -d "$t" ]
|
||||
then
|
||||
echo "Stowing $t"
|
||||
if [ -e "$t/PRESTOW" ]
|
||||
then
|
||||
echo "Running $t/PRESTOW"
|
||||
"$t/PRESTOW"
|
||||
fi
|
||||
|
||||
stow -t"$HOME" --ignore="^PRESTOW$" --ignore="^POSTSTOW$" "$t"
|
||||
|
||||
if [ -e "$t/POSTSTOW" ]
|
||||
then
|
||||
echo "Running $t/POSTSTOW"
|
||||
"$t/POSTSTOW"
|
||||
fi
|
||||
else
|
||||
echo "target $t does not exist or is not a directory"
|
||||
exit
|
||||
fi
|
||||
done
|
Loading…
Reference in New Issue
Block a user