wip
This commit is contained in:
@@ -2,8 +2,8 @@
|
||||
set -e
|
||||
|
||||
sudo rm -rf /tmp/archiso-work /tmp/archiso-out
|
||||
cd ~/know/archiso
|
||||
sudo mkarchiso -v -w /tmp/archiso-work -o /tmp/archiso-out "profile-$1"
|
||||
cd ~/dev
|
||||
sudo mkarchiso -v -w /tmp/archiso-work -o /tmp/archiso-out ~/dev/archiso-"$1"
|
||||
iso=(/tmp/archiso-out/*)
|
||||
sudo dd if="$iso" of="$2" status=progress bs=4M
|
||||
sudo rm -rf /tmp/archiso-work /tmp/archiso-out
|
||||
|
||||
@@ -43,67 +43,15 @@ remote_close() {
|
||||
echo close done
|
||||
}
|
||||
|
||||
declare -A repos
|
||||
add_repos_local() {
|
||||
while IFS= read -r -d $'\0'; do
|
||||
repo_path="$REPLY"
|
||||
[ ! -f "$repo_path/HEAD" ] && continue
|
||||
repo_path="$(realpath "$(dirname "$repo_path")")"
|
||||
repos["$repo_path"]=1
|
||||
done < <(find "$@" -type d -name .git -print0)
|
||||
push_homedir() {
|
||||
|
||||
}
|
||||
|
||||
add_repos_remote() {
|
||||
cd "$1"
|
||||
while IFS= read -r -d $'\0'; do
|
||||
repo_path="$REPLY"
|
||||
[ ! -f "$repo_path/HEAD" ] && continue
|
||||
repo_path="/$(dirname "$repo_path")"
|
||||
[[ ! " $(groups) " == *" $(echo "$repo_path" | cut -d'/' -f3) "* ]] && continue
|
||||
repos["$repo_path"]=1
|
||||
done < <(find "home" -type d -name '*.git' -print0 2>/dev/null)
|
||||
}
|
||||
|
||||
sync_one() {
|
||||
local_path="$1"
|
||||
remote_path="$2$1/$(basename "$1").git"
|
||||
echo "$local_path <-> $remote_path"
|
||||
remote_url="file:///$remote_path"
|
||||
if [ ! -d "$local_path" ]; then
|
||||
mkdir -p "$(dirname "$local_path")"
|
||||
git clone "$remote_url" "$local_path"
|
||||
else
|
||||
cd "$local_path"
|
||||
git add .
|
||||
git diff-index --quiet HEAD || git commit -m autocommit || true
|
||||
if [ ! -d "$remote_path" ]; then
|
||||
mkdir -p "$(dirname "$remote_path")"
|
||||
git clone --bare "file:///$1" "$remote_path"
|
||||
else
|
||||
git pull "$remote_url"
|
||||
git push "$remote_url"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
sync_repos() {
|
||||
for i in "${!repos[@]}"; do
|
||||
sync_one "$i" "$1"
|
||||
sync -f "$1"
|
||||
done
|
||||
}
|
||||
|
||||
if [[ "$1" = "open" ]]; then
|
||||
remote_open
|
||||
exit 0
|
||||
fi
|
||||
|
||||
remote_open
|
||||
add_repos_remote "$data_mnt"
|
||||
|
||||
for g in $(groups); do
|
||||
[ -d "/home/$g/dev" ] && add_repos_local "/home/$g/dev" -maxdepth 2
|
||||
[ -d "/home/$g/know" ] && add_repos_local "/home/$g/know" -maxdepth 2
|
||||
|
||||
done
|
||||
sync_repos "$data_mnt"
|
||||
|
||||
remote_close
|
||||
echo ALL OK
|
||||
|
||||
Reference in New Issue
Block a user