Commit b2f97315 authored by Natanael Copa's avatar Natanael Copa

vecho. -p option for password. thanks to Alexander Poslavsky

parent 838cb4b1
...@@ -62,6 +62,7 @@ check_openssl() { ...@@ -62,6 +62,7 @@ check_openssl() {
$OPENSSL list-cipher-commands | grep "^$ENCRYPTION$" > /dev/null \ $OPENSSL list-cipher-commands | grep "^$ENCRYPTION$" > /dev/null \
|| die "Cipher $ENCRYPTION is not supported" || die "Cipher $ENCRYPTION is not supported"
vecho "OPENSSL installed, cipher can be used"
} }
gen_current_tdb() { gen_current_tdb() {
...@@ -79,9 +80,9 @@ list_add() { ...@@ -79,9 +80,9 @@ list_add() {
while [ $# -gt 0 ] ; do while [ $# -gt 0 ] ; do
filename=`echo "$1" | sed 's:^/\+::'` filename=`echo "$1" | sed 's:^/\+::'`
if grep "^$filename$" "$list" >/dev/null 2>&1 ; then if grep "^$filename$" "$list" >/dev/null 2>&1 ; then
[ "$VERBOSE" ] echo "$filename is already in $list." vecho "$filename is already in $list."
else else
[ "$VERBOSE" ] && echo "Adding $filename to $list." vecho "Adding $filename to $list."
echo "$filename" >> "$list" echo "$filename" >> "$list"
fi fi
shift shift
...@@ -97,7 +98,7 @@ list_delete() { ...@@ -97,7 +98,7 @@ list_delete() {
while [ $# -gt 0 ] ; do while [ $# -gt 0 ] ; do
filename=`echo "$1" | sed 's:^/\+::'` filename=`echo "$1" | sed 's:^/\+::'`
mv "$list" "$tmp" mv "$list" "$tmp"
[ "$VERBOSE" ] && echo "Removing $filename from list." vecho "Removing $filename from list."
grep -v "^$filename$" "$tmp" > "$list" grep -v "^$filename$" "$tmp" > "$list"
rm "$tmp" rm "$tmp"
shift shift
...@@ -142,7 +143,7 @@ cmd_include() { ...@@ -142,7 +143,7 @@ cmd_include() {
show_include() { show_include() {
if [ -f "$INCLUDE_LIST" ] ; then if [ -f "$INCLUDE_LIST" ] ; then
[ "$VERBOSE" ] && echo "Include files:" vecho "Include files:"
cat "$INCLUDE_LIST" cat "$INCLUDE_LIST"
fi fi
} }
...@@ -193,6 +194,7 @@ cmd_package() { ...@@ -193,6 +194,7 @@ cmd_package() {
tmppkg="$tmpdir/$(basename $pkg)" tmppkg="$tmpdir/$(basename $pkg)"
# generate the packages.list # generate the packages.list
vecho "Generating package.list"
cd "$ROOT" cd "$ROOT"
mkdir -p $(dirname $PACKAGES_LIST) mkdir -p $(dirname $PACKAGES_LIST)
echo "#This file is generated by 'lbu package' (lbu $VERSION)" \ echo "#This file is generated by 'lbu package' (lbu $VERSION)" \
...@@ -211,6 +213,7 @@ cmd_package() { ...@@ -211,6 +213,7 @@ cmd_package() {
$SFIC --add "$CURRENT_TDB" $currentlist $SFIC --add "$CURRENT_TDB" $currentlist
# create tar archive # create tar archive
vecho "Creating tar archive"
[ -f "$EXCLUDE_LIST" ] && excl="-X $EXCLUDE_LIST" [ -f "$EXCLUDE_LIST" ] && excl="-X $EXCLUDE_LIST"
[ -f "$INCLUDE_LIST" ] && incl="-T $INCLUDE_LIST" [ -f "$INCLUDE_LIST" ] && incl="-T $INCLUDE_LIST"
if [ -n "$VERBOSE" ]; then if [ -n "$VERBOSE" ]; then
...@@ -225,15 +228,22 @@ cmd_package() { ...@@ -225,15 +228,22 @@ cmd_package() {
tar $excl $incl -c $currentlist | gzip -c >"$tmppkg" tar $excl $incl -c $currentlist | gzip -c >"$tmppkg"
rc=$? rc=$?
else else
tar $excl $incl -c $currentlist | gzip -c \ if [ -n "$PASSWORD" ]; then
| $OPENSSL enc "-$ENCRYPTION" -salt > "$tmppkg" tar $excl $incl -c $currentlist | gzip -c \
rc=$? | $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
fi fi
# actually commit unless dryrun mode # actually commit unless dryrun mode
if [ $rc -eq 0 ]; then if [ $rc -eq 0 ]; then
[ -z "$DRYRUN" ] && cp "$tmppkg" "$pkg" [ -z "$DRYRUN" ] && cp "$tmppkg" "$pkg"
vecho "Copied apk overlay to destination $pkg"
else else
rm -f "$CURRENT_TDB" rm -f "$CURRENT_TDB"
fi fi
...@@ -272,15 +282,19 @@ Options: ...@@ -272,15 +282,19 @@ Options:
-d Remove old apk overlay files. -d Remove old apk overlay files.
-e Protect configuration with a password. -e Protect configuration with a password.
-n Don't commit, just show what would have been commited. -n Don't commit, just show what would have been commited.
-p <password> Give encryption password on the command-line
-v Verbose mode. -v Verbose mode.
The following values for <media> is supported: floppy usb 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_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. used by setting the DEFAULT_CIPHER or ENCRYPTION environment variables.
For possible ciphers, try: openssl -v 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 The environment varialbes can also be set in $LBU_CONF
" "
exit 1 exit 1
...@@ -333,7 +347,7 @@ cmd_commit() { ...@@ -333,7 +347,7 @@ cmd_commit() {
if [ -n "$lines" ] && [ "$lines" != "$outfile" ]; then if [ -n "$lines" ] && [ "$lines" != "$outfile" ]; then
# More then one apkovl, this is a security concern # More then one apkovl, this is a security concern
[ -z "$was_mounted" ] && umount "$mnt" [ -z "$was_mounted" ] && umount "$mnt"
[ -n "$VERBOSE" ] && echo "$lines" vecho "$lines"
die "Found multiple apkovl files. Please use -d to replace them all." die "Found multiple apkovl files. Please use -d to replace them all."
fi fi
fi fi
...@@ -360,6 +374,7 @@ cmd_commit() { ...@@ -360,6 +374,7 @@ cmd_commit() {
# move current to commited. # move current to commited.
[ "$DRYRUN" ] || mv "$CURRENT_TDB" "$COMMITED_TDB" [ "$DRYRUN" ] || mv "$CURRENT_TDB" "$COMMITED_TDB"
vecho "Successfully saved apk overlay files"
} }
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
...@@ -398,7 +413,7 @@ cmd_exclude() { ...@@ -398,7 +413,7 @@ cmd_exclude() {
show_exclude() { show_exclude() {
if [ -f "$EXCLUDE_LIST" ] ; then if [ -f "$EXCLUDE_LIST" ] ; then
[ "$VERBOSE" ] && echo "Exclude files:" vecho "Exclude files:"
cat "$EXCLUDE_LIST" cat "$EXCLUDE_LIST"
fi fi
} }
...@@ -495,7 +510,7 @@ case "$cmd" in ...@@ -495,7 +510,7 @@ case "$cmd" in
esac esac
# parse common args # parse common args
while getopts "adehlM:nqrv" opt ; do while getopts "adehlM:np:qrv" opt ; do
case "$opt" in case "$opt" in
a) [ $SUBCMD = status ] || usage_$SUBCMD a) [ $SUBCMD = status ] || usage_$SUBCMD
USE_DEFAULT="-a" USE_DEFAULT="-a"
...@@ -514,6 +529,8 @@ while getopts "adehlM:nqrv" opt ; do ...@@ -514,6 +529,8 @@ while getopts "adehlM:nqrv" opt ; do
n) [ $SUBCMD = commit ] || usage_$SUBCMD n) [ $SUBCMD = commit ] || usage_$SUBCMD
DRYRUN="-n" DRYRUN="-n"
;; ;;
p) PASSWORD="$OPTARG"
;;
q) QUIET="$QUIET -q" q) QUIET="$QUIET -q"
;; ;;
r) REMOVE="-r" r) REMOVE="-r"
......
...@@ -21,6 +21,11 @@ echon () { ...@@ -21,6 +21,11 @@ echon () {
$ECHON "$*$NNL" $ECHON "$*$NNL"
} }
# echo if in verbose mode
vecho() {
[ -n "$VERBOSE" ] && echo "$@"
}
init_tmpdir() { init_tmpdir() {
local omask=`umask` local omask=`umask`
local __tmpd="/tmp/$PROGRAM-${$}-`date +%s`" local __tmpd="/tmp/$PROGRAM-${$}-`date +%s`"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment