aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNatanael Copa <ncopa@alpinelinux.org>2011-09-27 08:42:30 +0000
committerNatanael Copa <ncopa@alpinelinux.org>2011-09-27 08:52:54 +0000
commitb587245f7a1e0882f654fabc79e54915cd7cee59 (patch)
tree3b6ff2bfd27385687cea947abb36a43c2aa1e17e
parent6653228344ed532fe4cf2878c442ccb5fedea250 (diff)
downloadalpine-conf-b587245f7a1e0882f654fabc79e54915cd7cee59.tar.bz2
alpine-conf-b587245f7a1e0882f654fabc79e54915cd7cee59.tar.xz
lbu: implement LBU_BACKUPDIR
This allows users to do lbu commit into a dir without trying to mount anything.
-rw-r--r--lbu.conf4
-rw-r--r--lbu.in38
2 files changed, 27 insertions, 15 deletions
diff --git a/lbu.conf b/lbu.conf
index df05134..fbb8404 100644
--- a/lbu.conf
+++ b/lbu.conf
@@ -8,5 +8,9 @@ DEFAULT_CIPHER=aes-256-cbc
# Can also be set to 'floppy'
# LBU_MEDIA=usb
+# Set the LBU_BACKUPDIR variable in case you prefer to save the apkovls
+# in a normal directory instead of mounting an external media.
+# LBU_BACKUPDIR=/root/config-backups
+
# Uncomment below to let lbu make up to 3 backups
# BACKUP_LIMIT=3
diff --git a/lbu.in b/lbu.in
index 5d74b3d..92cdd31 100644
--- a/lbu.in
+++ b/lbu.in
@@ -160,10 +160,12 @@ list_delete() {
unpack_apkovl() {
local f="$(hostname).apkovl.tar.gz"
local dest="$1"
- local mnt="/media/$LBU_MEDIA"
+ local mnt="${LBU_BACKUPDIR:-/media/$LBU_MEDIA}"
local count=0
mkdir -p "$dest"
- mount_once "$mnt"
+ if [ -n "$LBU_MEDIA" ]; then
+ mount_once "$mnt"
+ fi
if [ -n "$ENCRYPTION" ]; then
f="$f.$ENCRYPTION"
fi
@@ -389,7 +391,8 @@ Options:
-v Verbose mode.
The following values for <media> is supported: floppy usb
-If <media> is not specified, the environment variable LBU_MEDIA will be used.
+If <media> is not specified, the environment variable LBU_BACKUPDIR or
+LBU_MEDIA will be used. If LBU_BACKUPDIR is set, nothing will be mounted.
Password protection will use $DEFAULT_CIPHER encryption. Other ciphers can be
used by setting the DEFAULT_CIPHER or ENCRYPTION environment variables.
@@ -412,14 +415,17 @@ cmd_commit() {
# turn on verbose mode if dryrun
[ -n "$DRYRUN" ] && VERBOSE="-v"
- # find what media to use
- media="${1:-$LBU_MEDIA}"
- [ -z "$media" ] && usage_commit
+ mnt="$LBU_BACKUPDIR"
+ if [ -z "$mnt" ]; then
+ # find what media to use
+ media="${1:-$LBU_MEDIA}"
+ [ -z "$media" ] && usage_commit
- # mount media unles its already mounted
- mnt=/media/$media
- [ -d "$mnt" ] || usage
- mount_once_rw "$mnt" || die "failed to mount $mnt"
+ # mount media unles its already mounted
+ mnt=/media/$media
+ [ -d "$mnt" ] || usage
+ mount_once_rw "$mnt" || die "failed to mount $mnt"
+ fi
# find the outfile
outfile="$mnt/$(hostname).apkovl.tar.gz"
@@ -541,10 +547,12 @@ EOF
cmd_listbackup() {
local media=${1:-"$LBU_MEDIA"}
- local mnt="/media/$media"
- [ -z "$media" ] && usage_listbackup
+ local mnt="${LBU_BACKUPDIR:-/media/$media}"
+ [ -z "$media" ] && [ -z "$LBU_BACKUPDIR" ] && usage_listbackup
- mount_once "$mnt" || die "failed to mount $mnt"
+ if [ -n "$media" ]; then
+ mount_once "$mnt" || die "failed to mount $mnt"
+ fi
ls -1 "$mnt"/*.[0-9][0-9]*[0-9][0-9].tar.gz* 2>/dev/null | sed 's:.*/::'
}
@@ -600,7 +608,7 @@ cmd_status() {
return 0
fi
LBU_MEDIA=${1:-"$LBU_MEDIA"}
- [ -z "$LBU_MEDIA" ] && usage_status
+ [ -z "$LBU_MEDIA" ] && [ -z "$LBU_BACKUPDIR" ] && usage_status
local tmp
init_tmpdir tmp
mkdir -p "$tmp/a" "$tmp/b"
@@ -654,7 +662,7 @@ usage: $PROGRAM diff [<media>]
cmd_diff() {
LBU_MEDIA=${1:-"$LBU_MEDIA"}
- [ -z "$LBU_MEDIA" ] && usage_diff
+ [ -z "$LBU_MEDIA" ] && [ -z "$LBU_BACKUPDIR" ] && usage_diff
local tmp
init_tmpdir tmp
mkdir -p "$tmpdir/a" "$tmp/b"