summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNatanael Copa <ncopa@alpinelinux.org>2007-10-16 17:55:45 +0000
committerNatanael Copa <ncopa@alpinelinux.org>2007-10-16 17:55:45 +0000
commitb2f97315c17db0cde26b9e070ee73fdb8e57290c (patch)
treee4cb11c6f50905c536ed976941f504e3e5c58281
parent838cb4b1494ab9c3cfc7c0a952aaf220625758df (diff)
downloadalpine-conf-b2f97315c17db0cde26b9e070ee73fdb8e57290c.tar.bz2
alpine-conf-b2f97315c17db0cde26b9e070ee73fdb8e57290c.tar.xz
vecho. -p option for password. thanks to Alexander Poslavsky
-rw-r--r--lbu39
-rwxr-xr-xlibalpine.sh5
2 files changed, 33 insertions, 11 deletions
diff --git a/lbu b/lbu
index 783cb15..9c91669 100644
--- a/lbu
+++ b/lbu
@@ -62,6 +62,7 @@ check_openssl() {
$OPENSSL list-cipher-commands | grep "^$ENCRYPTION$" > /dev/null \
|| die "Cipher $ENCRYPTION is not supported"
+ vecho "OPENSSL installed, cipher can be used"
}
gen_current_tdb() {
@@ -79,9 +80,9 @@ list_add() {
while [ $# -gt 0 ] ; do
filename=`echo "$1" | sed 's:^/\+::'`
if grep "^$filename$" "$list" >/dev/null 2>&1 ; then
- [ "$VERBOSE" ] echo "$filename is already in $list."
+ vecho "$filename is already in $list."
else
- [ "$VERBOSE" ] && echo "Adding $filename to $list."
+ vecho "Adding $filename to $list."
echo "$filename" >> "$list"
fi
shift
@@ -97,7 +98,7 @@ list_delete() {
while [ $# -gt 0 ] ; do
filename=`echo "$1" | sed 's:^/\+::'`
mv "$list" "$tmp"
- [ "$VERBOSE" ] && echo "Removing $filename from list."
+ vecho "Removing $filename from list."
grep -v "^$filename$" "$tmp" > "$list"
rm "$tmp"
shift
@@ -142,7 +143,7 @@ cmd_include() {
show_include() {
if [ -f "$INCLUDE_LIST" ] ; then
- [ "$VERBOSE" ] && echo "Include files:"
+ vecho "Include files:"
cat "$INCLUDE_LIST"
fi
}
@@ -193,6 +194,7 @@ cmd_package() {
tmppkg="$tmpdir/$(basename $pkg)"
# generate the packages.list
+ vecho "Generating package.list"
cd "$ROOT"
mkdir -p $(dirname $PACKAGES_LIST)
echo "#This file is generated by 'lbu package' (lbu $VERSION)" \
@@ -211,6 +213,7 @@ cmd_package() {
$SFIC --add "$CURRENT_TDB" $currentlist
# create tar archive
+ vecho "Creating tar archive"
[ -f "$EXCLUDE_LIST" ] && excl="-X $EXCLUDE_LIST"
[ -f "$INCLUDE_LIST" ] && incl="-T $INCLUDE_LIST"
if [ -n "$VERBOSE" ]; then
@@ -225,15 +228,22 @@ cmd_package() {
tar $excl $incl -c $currentlist | gzip -c >"$tmppkg"
rc=$?
else
- tar $excl $incl -c $currentlist | gzip -c \
- | $OPENSSL enc "-$ENCRYPTION" -salt > "$tmppkg"
- rc=$?
+ if [ -n "$PASSWORD" ]; then
+ tar $excl $incl -c $currentlist | gzip -c \
+ | $OPENSSL enc "-$ENCRYPTION" -salt -pass pass:"$PASSWORD" > "$tmppkg"
+ rc=$?
+ else
+ tar $excl $incl -c $currentlist | gzip -c \
+ | $OPENSSL enc "-$ENCRYPTION" -salt > "$tmppkg"
+ rc=$?
+ fi
fi
fi
# actually commit unless dryrun mode
if [ $rc -eq 0 ]; then
[ -z "$DRYRUN" ] && cp "$tmppkg" "$pkg"
+ vecho "Copied apk overlay to destination $pkg"
else
rm -f "$CURRENT_TDB"
fi
@@ -272,15 +282,19 @@ Options:
-d Remove old apk overlay files.
-e Protect configuration with a password.
-n Don't commit, just show what would have been commited.
+ -p <password> Give encryption password on the command-line
-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.
-Passows protection will use $DEFAULT_CIPHER encryption. Other ciphers can be
+Password protection will use $DEFAULT_CIPHER encryption. Other ciphers can be
used by setting the DEFAULT_CIPHER or ENCRYPTION environment variables.
For possible ciphers, try: openssl -v
+The password used to encrypt the file, can either be specified on the command line
+(following -p) or using the ENCRYPTION environment variable in /etc/lbu/lbu.conf
+
The environment varialbes can also be set in $LBU_CONF
"
exit 1
@@ -333,7 +347,7 @@ cmd_commit() {
if [ -n "$lines" ] && [ "$lines" != "$outfile" ]; then
# More then one apkovl, this is a security concern
[ -z "$was_mounted" ] && umount "$mnt"
- [ -n "$VERBOSE" ] && echo "$lines"
+ vecho "$lines"
die "Found multiple apkovl files. Please use -d to replace them all."
fi
fi
@@ -360,6 +374,7 @@ cmd_commit() {
# move current to commited.
[ "$DRYRUN" ] || mv "$CURRENT_TDB" "$COMMITED_TDB"
+ vecho "Successfully saved apk overlay files"
}
#---------------------------------------------------------------------------
@@ -398,7 +413,7 @@ cmd_exclude() {
show_exclude() {
if [ -f "$EXCLUDE_LIST" ] ; then
- [ "$VERBOSE" ] && echo "Exclude files:"
+ vecho "Exclude files:"
cat "$EXCLUDE_LIST"
fi
}
@@ -495,7 +510,7 @@ case "$cmd" in
esac
# parse common args
-while getopts "adehlM:nqrv" opt ; do
+while getopts "adehlM:np:qrv" opt ; do
case "$opt" in
a) [ $SUBCMD = status ] || usage_$SUBCMD
USE_DEFAULT="-a"
@@ -514,6 +529,8 @@ while getopts "adehlM:nqrv" opt ; do
n) [ $SUBCMD = commit ] || usage_$SUBCMD
DRYRUN="-n"
;;
+ p) PASSWORD="$OPTARG"
+ ;;
q) QUIET="$QUIET -q"
;;
r) REMOVE="-r"
diff --git a/libalpine.sh b/libalpine.sh
index 8b68bd7..776031a 100755
--- a/libalpine.sh
+++ b/libalpine.sh
@@ -21,6 +21,11 @@ echon () {
$ECHON "$*$NNL"
}
+# echo if in verbose mode
+vecho() {
+ [ -n "$VERBOSE" ] && echo "$@"
+}
+
init_tmpdir() {
local omask=`umask`
local __tmpd="/tmp/$PROGRAM-${$}-`date +%s`"