#!/bin/sh #------------------------------------------------------------------------------ # /var/install/bin/carddav2xml-cronjob-cmd - Cronjob command # # Copyright (c) 2015-2019 The Eisfair Team, team(at)eisfair(dot)org # # Creation: 2016-06-23 jed # Last Update: $Id$ # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. #------------------------------------------------------------------------------ # read eislib . /var/install/include/eislib . /var/install/include/jedlib pgmname=`basename $0` module_name=`echo "${pgmname}" | cut -d- -f1` # debug mode true/false #debug=true if ${debug:-false} then exec 2> /tmp/${pgmname}-trace$$.log set -x ask_debug=true export ask_debug fi carddav2xml_runpath=/var/lib/${module_name} package_configfile=/etc/config.d/${module_name} carddav2xml_bin=/usr/lib/${module_name}/${module_name}.php idx=$1 if ! is_numeric "${idx}" then idx='' fi if [ -f ${package_configfile} ] then . ${package_configfile} if [ "${START_CARDDAV2XML}" = 'yes' ] then if [ -n "${idx}" ] then # number given on command line if [ ${idx} -le ${CARDDAV2XML_N} ] then # index number is in range eval active='$CARDDAV2XML_'${idx}'_ACTIVE' if [ "${active}" = 'yes' ] then # active record found # config2xml-x.php config_file="${carddav2xml_runpath}/config`echo "${module_name}" | sed -r 's/^.{7}//'`-${idx}.php" log_file=/var/log/${module_name}-${idx}-output-trace.log eval post_exec_cmd='$CARDDAV2XML_'${idx}'_CRON_POST_EXEC' if [ -n "`echo "${post_exec_cmd}" | sed 's/ *//g'`" ] then if [ ! -x ${post_exec_cmd} ] then post_exec_cmd='' fi else post_exec_cmd='' fi # run command ( /usr/bin/php -f ${carddav2xml_bin} ${config_file} ; ${post_exec_cmd} ) | sed -e 's/[[:cntrl:]]\[32m//g' -e 's/[[:cntrl:]]\[0m//g' > ${log_file} # check if an error has been reported grep -v -i "WARNING: no phone entry found. VCard will be ignored." ${log_file} | grep -E -i -q "ERROR:|WARNING:" if [ $? -eq 0 ] then grep -E -i "ERROR:|WARNING:" ${log_file} | \ grep -E -v -i "WARNING: no phone entry found. VCard will be ignored.|WARNING: Only jpg contact photos are currently supported." | sed 's/^ *//' sed '$!N;/WARNING: Only jpg contact photos are currently supported/P;D' ${log_file} | sed 's/^ *//' fi fi fi else echo "Error: No valid configuration set number ($1) given on command line!" fi fi else echo "Error: Configuration file '${package_configfile}' doesn't exist!" fi exit 0