#!/bin/sh # # Script to import lua program files # Parameters: # $1: password used to decrypt the zip file # $2: imported file to unpack # $3: destRootDir to unpack # $4: target destDir where the unpacked file is copied (create when does not exist) # Configuration IMPORTER=/home/tool/bin/7za TARGET_DIR=/home/tool/config # check importer if [ ! -e $IMPORTER ]; then echo "Importer not found" >&2 exit 1 fi # password check if [ $# -eq 0 ]; then echo "Password required" >&2 exit 1 fi PWD=$1 if [ "$PWD" = "" ]; then echo "No empty password" >&2 exit 1 fi if [ $# -eq 1 ]; then echo "Import file name required" >&2 exit 1 fi IMPORTFNAME=$2 if [ "$IMPORTFNAME" = "" ]; then echo "Empty import file name given" >&2 exit 1 fi if [ $# -eq 2 ]; then echo "Target root path name required" >&2 exit 1 fi TARGETROOT=$3 if [ "$TARGETROOT" = "" ]; then echo "Empty target root path name given" >&2 exit 1 fi if [ $# -eq 3 ]; then echo "Target dest path name required" >&2 exit 1 fi TARGETDEST=$4 if [ "$TARGETDEST" = "" ]; then echo "Empty target dest path name given" >&2 exit 1 fi # check each path if [ ! -e $TARGETROOT ]; then echo "Root path not found" >&2 exit 1 fi TARGET_DIR=$TARGETROOT$TARGETDEST if [ ! -e $TARGET_DIR ]; then echo "Dest path not found.. creating" >&2 mkdir $TARGET_DIR else echo "Dest path IS found" >&2 fi echo "Deleting content" >&2 rm -f $TARGET_DIR/* # check source file INPUT_FILE=$TARGETROOT$IMPORTFNAME if [ ! -e $INPUT_FILE ]; then echo "Export file not found" >&2 exit 1 fi $IMPORTER t $INPUT_FILE -p$PWD > /dev/null RETVAL=$? if [ $RETVAL -eq 2 ];then echo "Wrong configuration version" >&2 exit 1 fi if [ $RETVAL -ne 0 ];then echo Failure exit $RETVAL fi $IMPORTER x $INPUT_FILE -p$PWD -o$TARGET_DIR -y > /dev/null sync RETVAL=$? if [ $RETVAL -eq 0 ];then echo Success dbus-send --system --print-reply --dest=com.rexroth.akku.SysService /SysObj com.rexroth.akku.SysInterface.fcfgfilechanged string:"/home/tool/config/job_importer" fi if [ $RETVAL -ne 0 ];then echo Failure fi exit $RETVAL