- Validation: `check_tools`, `check_boot_device_layout`,
`check_partition_mountable` (takes the partition as explicit `$1`; callers
now always pass `PATH_PARTITION_LUKSVG`/`PATH_PARTITION_EFI`),
- `check_new_luksvg`, `check_openable_luksvg`, `usage` (arg-count check with
- auto-built usage message). The boot-label legality check in
+ `check_new_luksvg`, `check_openable_luksvg`,
+ `check_path_is_git_checkout <path>` (has a `.git`), `usage` (arg-count
+ check with auto-built usage message). The boot-label legality check in
`install_debian.sh` is an inline `case`, not a helper, since it's the only
caller left.
- LUKS lifecycle: `open_luksvg`/`close_luksvg` operate on the global
succeeds — wraps every `passwd` call so mismatched passwords re-prompt
instead of aborting via errexit. `create_lv` wraps
`lvcreate -L <size> -n <lv> <vg>` with narration.
+- `point_repo_origin <path-checkout> <url>` sets that checkout's `origin`
+ to `<url>` (`remote set-url`, or `remote add` if it has none); used by
+ `setup_git_server.sh` and `adopt_repo.sh`.
- `efi_copy_kernel_vmlinuz <efi-dir> [<root-prefix>]` copies
`FNAME_VMLINUZ`/`FNAME_INITRD` into an EFI boot directory; empty prefix
means the running system's own `/`. `install_debian.sh` passes
include OPTS_SSH_NEW_HOST
include PATH_GIT_BASE
include USERNAME
+include check_path_is_git_checkout
include check_tools
include error
include msg
-include try_quiet
+include point_repo_origin
include usage
# inputs to confirm
LOGIN="${USERNAME}@${SERVER}"
# early sanity check, with further-down constant declarations relying on this …
-[ -d "${PATH_SRC_REPO}/.git" ]\
- || error "${PATH_SRC_REPO}: not a git checkout"
+check_path_is_git_checkout "${PATH_SRC_REPO}"
# constants derived from changeables
NAME_REPO=$(basename "$(cd "${PATH_SRC_REPO}" && pwd)")
git -C "${PATH_SRC_REPO}" push --quiet "${URL_REMOTE_REPO}" \
'refs/heads/*:refs/heads/*' 'refs/tags/*:refs/tags/*'
-msg "Pointing this checkout's origin at %s …" "${SERVER}"
-if try_quiet git -C "${PATH_SRC_REPO}" remote get-url origin; then
- PUSHURL=$(git -C "${PATH_SRC_REPO}" config --get remote.origin.pushurl)\
- || PUSHURL=""
- git -C "${PATH_SRC_REPO}" remote set-url origin "${URL_REMOTE_REPO}"
- if [ -n "${PUSHURL}" ] && [ "${PUSHURL}" != "${URL_REMOTE_REPO}" ]; then
- msg 'Note: origin also has a separate pushurl (%s)' "${PUSHURL}"
- msg 'left untouched; a bare git push will still use it. To also'
- msg 'repoint pushes here:'
- msg ' git remote set-url --push origin %s' "${URL_REMOTE_REPO}"
- fi
-else
- git -C "${PATH_SRC_REPO}" remote add origin "${URL_REMOTE_REPO}"
+point_repo_origin "${PATH_SRC_REPO}" "${URL_REMOTE_REPO}"
+PUSHURL=$(git -C "${PATH_SRC_REPO}" config --get remote.origin.pushurl)\
+ || PUSHURL=""
+if [ -n "${PUSHURL}" ] && [ "${PUSHURL}" != "${URL_REMOTE_REPO}" ]; then
+ msg 'Note: origin also has a separate pushurl (%s)' "${PUSHURL}"
+ msg 'left untouched; a bare git push will still use it. To also'
+ msg 'repoint pushes here:'
+ msg ' git remote set-url --push origin %s' "${URL_REMOTE_REPO}"
fi
msg '%s is now authoritative for %s.' "${SERVER}" "${NAME_REPO}"
--- /dev/null
+include error
+
+check_path_is_git_checkout() {
+ local PATH_CHECKOUT=$1
+ [ -d "${PATH_CHECKOUT}/.git" ]\
+ || error "${PATH_CHECKOUT}: not a git checkout"
+}
--- /dev/null
+include msg
+include try_quiet
+
+point_repo_origin() {
+ local PATH_CHECKOUT=$1
+ local URL_ORIGIN=$2
+ msg "Pointing %s's origin at %s …" "${PATH_CHECKOUT}" "${URL_ORIGIN}"
+ if try_quiet git -C "${PATH_CHECKOUT}" remote get-url origin; then
+ git -C "${PATH_CHECKOUT}" remote set-url origin "${URL_ORIGIN}"
+ else
+ git -C "${PATH_CHECKOUT}" remote add origin "${URL_ORIGIN}"
+ fi
+}
include PATH_GIT_BASE
include PATH_REPO
include USERNAME
-include error
+include check_path_is_git_checkout
include msg
+include point_repo_origin
include render_template
-include try_quiet
# constants derived from changeables
FNAME_GIT_DAEMON_UNIT=git-daemon.service
PATH_SELF_HOSTED="${PATH_GIT_BASE}/${DIRNAME_REPO}.git"
URL_SELF_HOSTED_LOCAL="git://localhost/${DIRNAME_REPO}.git"
-# early sanity check, so we fail before changing anything
-[ -d "${PATH_REPO}/.git" ]\
- || error "${PATH_REPO}: not a git checkout, so cannot host it"
+# sanity checks
+check_path_is_git_checkout "${PATH_REPO}"
msg 'Ensuring installation of git …'
apt-get -y update
chown -R "${USERNAME}:${USERNAME}" "${PATH_SELF_HOSTED}"
fi
-msg "Pointing %s's origin at %s …" "${PATH_REPO}" "${URL_SELF_HOSTED_LOCAL}"
-if try_quiet git -C "${PATH_REPO}" remote get-url origin; then
- git -C "${PATH_REPO}" remote set-url origin "${URL_SELF_HOSTED_LOCAL}"
-else
- git -C "${PATH_REPO}" remote add origin "${URL_SELF_HOSTED_LOCAL}"
-fi
+point_repo_origin "${PATH_REPO}" "${URL_SELF_HOSTED_LOCAL}"
msg 'Ready. To make the checkout you commit in push here, run there:'
msg ' git remote set-url origin ssh://%s@<this-server>%s' \