Browse Source

Fix some issues in generated scripts; make passphrase non-executable

master
Jim Paris 10 months ago
parent
commit
0f82c74aaa
3 changed files with 23 additions and 10 deletions
  1. +11
    -2
      Makefile
  2. +4
    -1
      README.md
  3. +8
    -7
      borg-setup.sh

+ 11
- 2
Makefile View File

@@ -1,8 +1,17 @@
test:
.PHONY: all
all:
@echo "Use 'make dist' to copy to https://psy.jim.sh/borg-setup.sh"

.PHONY: check
check:
shellcheck -f gcc borg-setup.sh

.PHONY: test
test:
rm -rf /tmp/test-borg
BORG_DIR=/tmp/test-borg ./borg-setup.sh
ls -al /tmp/test-borg

dist:
.PHONY: dist
dist: check
scp borg-setup.sh psy:/www/psy

+ 4
- 1
README.md View File

@@ -16,4 +16,7 @@

# Usage

Run `borg-setup.sh` on a client
Run on client:

wget https://psy.jim.sh/borg-setup.sh
sudo ./borg-setup.sh

+ 8
- 7
borg-setup.sh View File

@@ -81,7 +81,7 @@ create_borg_wrapper()
#!/bin/sh

export BORG_REPO=${BORG_REPO}
export BORG_PASSCOMMAND=${BORG_DIR}/print-passphrase
export BORG_PASSCOMMAND="cat ${BORG_DIR}/passphrase"
export BORG_HOST_ID=${HOSTID}
export BORG_BASE_DIR=${BORG_DIR}
export BORG_CACHE_DIR=${BORG_DIR}/cache
@@ -105,11 +105,8 @@ generate_keys()
{
PASS_SSH=$(print_random_key)
PASS_REPOKEY=$(print_random_key)
cat >"${BORG_DIR}/print-passphrase" <<EOF
#!/bin/sh
echo $PASS_REPOKEY
EOF
chmod 700 "${BORG_DIR}/print-passphrase"
echo "$PASS_REPOKEY" > "${BORG_DIR}/passphrase"
chmod 600 "${BORG_DIR}/passphrase"
}

# Run a command on the remote host over an existing SSH tunnel
@@ -227,7 +224,7 @@ set -e
# from different filesystems. If not, duplicates have no effect.
DIRS="/"
for DIR in /usr /var /home /boot /efi ; do
if [ -e $DIR ] ; then
if [ -e "\$DIR" ] ; then
DIRS="\$DIRS \$DIR"
fi
done
@@ -290,6 +287,10 @@ fi
echo "Unmount with: fusermount -u \$1"

EOF

chmod 755 "${BORG_DIR}/backup.sh"
chmod 755 "${BORG_DIR}/prune.sh"
chmod 755 "${BORG_DIR}/mount.sh"
}

configure_systemd()


Loading…
Cancel
Save