diff --git a/stpkg b/stpkg index 2ec001668be6848ca7f391c74e34339db131979d..d1d47c5dd5758ed921674255f75f15593135eb3f 100755 --- a/stpkg +++ b/stpkg @@ -239,6 +239,7 @@ __install() { # Create the ~/config/stpkg.sh [ ! -d ~/config ] && mkdir ~/config cat > $STPKG_CONF_FILE << EOF +# Please, only modify the 'STPKG_TOKEN' if [ ! "x\$INSTALL" = "xyes" ]; then STPKG_BASE="$BASE_DIR" STPKG_HOMESERV='matrix.org' @@ -263,10 +264,14 @@ STPKG_INSTALL="$STPKG_INSTALL" SSHFS_USER="$SSHFS" SSHFS_MNT="`echo "$MNT" | sed "s+$HOME+~+g"`" mountpoint $MNT >/dev/null 2>&1 -if [ \$? -ne 0 -a ! "x\$INSTALL" = "xyes" ]; then -[ ! -d "\$STPKG_INSTALL" ] && { sshfs $SSHFS: $MNT || die "Failed to mount $SSHFS:~/ to $MNT"; } -[ ! -d "\$STPKG_INSTALL" ] && die 'Failed to mount $SSHFS:~/ to $MNT, sshfs problems?' -fi +[ \$? -ne 0 -a ! "x\$INSTALL" = "xyes" ] && { + [ ! -d "\$STPKG_INSTALL" ] && { + sshfs $SSHFS: $MNT \ + || die "Failed to mount $SSHFS:~/ to $MNT"; + } + [ ! -d "\$STPKG_INSTALL" ] \ + && die 'Failed to mount $SSHFS:~/ to $MNT, sshfs problems?' +} EOF # Do the sshfs hook @@ -320,10 +325,8 @@ if [ ! -d "$STPKG_INSTALL" ]; then fi info "Use STPKG_INSTALL: $STPKG_INSTALL`[ "x$STPKG_SSHFS" = "xyes" ] && echo ' (this is an sshfs install)'`" -if [ "x$STPKG_BASE" = "x" ]; then - die "The STPKG_BASE env var is mendatory, it must point to the sticker repo." \ - "It should have been given by the install script" -fi +[ "x$STPKG_BASE" = "x" ] && die \ + "The STPKG_BASE env var is mendatory, it must point to the sticker repo. It should have been given by the install script" ######################### # Cmd handler functions # @@ -337,15 +340,18 @@ __show() { local REVISION=`expr $COMMITS - $REVISION` local BRANCH=`git -C $STPKG_BASE branch 2>&1 | grep --color=auto "\*" | sed -e "s/* //" -e "s/$/ /"` - ## SSHFS stuff - if [ "x$STPKG_SSHFS" = "xyes" ]; then -cat << EOF -`__bold stpkg with sshfs install:` - sshfs `[ -d $STPKG_INSTALL ] && __green 'mounted' || __yellow 'umounted'` - user $SSHFS_USER - mountpoint $SSHFS_MNT -EOF - fi + local SAFE=0 + local UNSAFE=0 + local UNSAFE_CMD="" + for CMD in $REQUIREMENTS; do + [[ "`which $CMD`" =~ ^(/usr/bin|/bin|/sbin|/usr/sbin) ]] \ + && local SAFE=`expr $SAFE + 1` \ + || { + local UNSAFE=`expr $UNSAFE + 1` + local UNSAFE_CMD="$CMD $UNSAFE_CMD" + } + done + [ $UNSAFE -gt 0 ] && local UNSAFE=`__yellow $UNSAFE` || local UNSAFE=`__green $UNSAFE` if [ "x$STPKG_TOKEN" = "x" ]; then local TOKEN=`__yellow 'absent' ` @@ -359,16 +365,22 @@ EOF local TOKEN="$TOKEN `__red "Sensitive data, I won't show it!"`" fi + ## SSHFS stuff + if [ "x$STPKG_SSHFS" = "xyes" ]; then +cat << EOF +`__bold stpkg with sshfs install:` + sshfs `[ -d $STPKG_INSTALL ] && __green 'mounted' || { __yellow 'umounted'; echo " (should not be the case at this point)"; }` + user $SSHFS_USER + mountpoint $SSHFS_MNT +EOF + fi + ## Version stuff cat << EOF `__bold stpkg version:` branch $BRANCH commits $COMMITS revision $REVISION -EOF - - ## Variable and commands stuff -cat << EOF `__bold stpkg options and variables:` `__green STPKG_INSTALL` `__italic $STPKG_INSTALL` `__green STPKG_BASE` `__italic $STPKG_BASE` @@ -377,12 +389,14 @@ cat << EOF `__green STPKG_HOMESERV` `__italic $STPKG_HOMESERV` `__green STPKG_TOKEN` $TOKEN `__bold aliased commands due to the '"require"' function:` + safe (system) `__green $SAFE` + unsafe (user) $UNSAFE EOF - for CMD in $REQUIREMENTS; do - echo -e " `__green $CMD` `which $CMD`" - done | sort | column -t | while IFS= read LINE; do - echo " $LINE" - done + [ ! -z "$UNSAFE_CMD" ] && { + echo -ne ' '`__yellow unsafe commands`' ' + for CMD in $UNSAFE_CMD; do echo -n "$CMD "; done + echo '' + } } __update() {