#!/bin/sh #------------------------------------------------------------------------------ # /var/install/bin/carddav2xml-force-update - force update of FRITZ!Box # address book # # Copyright (c) 2015-2019 The Eisfair Team, team(at)eisfair(dot)org # # Creation: 2015-04-11 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/check-eisfair-version 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 title_str='Force manual XML export' if [ -f ${package_configfile} ] then . ${package_configfile} if [ "${START_CARDDAV2XML}" = 'yes' ] then ### list available configuration sets ### clrhome mecho --info "Selective CardDAV file export" mecho mecho "Which export do you want to force?" mecho techo --begin 1 3 2 30 techo --row "" --info "Nr" "" --info "Comment" idx=1 active_entries=':' while [ ${idx} -le ${CARDDAV2XML_N} ] do eval active='$CARDDAV2XML_'${idx}'_ACTIVE' if [ "${active}" = 'yes' ] then eval comment='$CARDDAV2XML_'${idx}'_COMMENT' techo --row "" ${idx} ":" "${comment}" active_entries="${active_entries}${idx}:" fi idx=`/usr/bin/expr ${idx} + 1` done techo --end mecho idxmax=`/usr/bin/expr ${idx} - 1` endflag=0 if [ ${idxmax} -gt 0 ] then until [ ${endflag} = 1 ] do /var/install/bin/ask "Please enter entry number (1-${idxmax}) or (q)uit:" '' '+' > /tmp/ask.$$ rc=$? nbr=`cat /tmp/ask.$$` rm -f /tmp/ask.$$ if [ $rc = 255 ] then exit 1 fi case "${nbr}" in [qQ] ) ### quit ### endflag=1 exit 1 ;; [0-9] | [1-9][0-9] ) ### number entered ### if [ ${nbr} -ge 1 -a ${nbr} -le ${idxmax} ] then echo "${active_entries}" | grep -q ":${nbr}:" if [ $? -eq 0 ] then # config2xml-x.php config_file="${carddav2xml_runpath}/config`echo "${module_name}" | sed -r 's/^.{7}//'`-${nbr}.php" log_file=/var/log/${module_name}-${nbr}-force-output-trace.log # create empty output file if [ ! -f ${log_file} ] then echo > ${log_file} fi # check post execution command eval post_exec_cmd='$CARDDAV2XML_'${nbr}'_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 # force update ( /usr/bin/php -f ${carddav2xml_bin} ${config_file} ; ${post_exec_cmd} ) | sed -e 's/[[:cntrl:]]\[32m//g' -e 's/[[:cntrl:]]\[0m//g' > ${log_file} # show output if [ -s ${log_file} ] then # check if show-doc.cui supports colors color='' frame='' if $(grep -qE "^MENU=['\"]/var/install/bin/show-menu['\"]" /etc/config.d/setup) then color='--nocolor' frame='--noframe' fi /var/install/bin/show-doc.cui ${color} ${frame} --follow --title "${title_str}" ${log_file} fi rm -f ${log_file} endflag=1 fi fi ;; * ) ;; esac done else mecho --info "There are currently no configuration sets defined!" fi mecho anykey fi #else # mecho --error "Configuration file '${package_configfile}' doesn't exist!" fi exit 0