#!/bin/bash declare -i cfgnum if [ $1 = "install" ]; then FILE="${VHOST_CGIBINDIR}/webmo/interfaces/._cfg*_globals.int" sed -i \ -e "s:^htmlBase.*:htmlBase=\"${VHOST_HTDOCSDIR}/webmo\":g" \ -e "s:^cgiBase.*:cgiBase=\"${VHOST_CGIBINDIR}/webmo\" :g" \ -e "s:userBase.*:userBase=\"${VHOST_ROOT}/webmo\":g" \ ${FILE} pushd ${VHOST_CGIBINDIR}/webmo/interfaces > /dev/null # If a program is enabled, install .int.disabled changes to .int for file in *.disabled; do enabled_file=${file%.disabled} echo -n "Checking for enabled interface '${enabled_file}' ... " if [[ -e ${enabled_file} ]]; then echo "yes" for (( cfgnum=10#0000; cfgnum < 10#9999; cfgnum++ )); do # A number can't be padded with zero's, but a string can cfgstr=$(printf "%.4d" ${cfgnum}) enabled_cfgfile=._cfg${cfgstr}_${enabled_file} if [[ ! -e ${enabled_cfgfile} ]]; then mv ${file} ${enabled_cfgfile} break fi done else echo "no" fi done # Handle ._cfg* files properly, whether interfaces are enabled or not for file in ._cfg*disabled; do realfile=${file#._cfg*_} enabled_file=${realfile%.disabled} # If interface is enabled, then rename the config file # But be considerate of other unmerged config files if [[ -e ${enabled_file} ]]; then cfgnum=${file%.disabled} cfgnum=${cfgnum#._cfg} cfgnum=10#${cfgnum%%_*} for (( ; cfgnum < 10#9999; cfgnum++ )); do # A number can't be padded with zero's, but a string can cfgstr=$(printf "%.4d" ${cfgnum}) enabled_cfgfile=._cfg${cfgstr}_${enabled_file} if [[ ! -e ${enabled_cfgfile} ]]; then mv ${file} ${enabled_cfgfile} break fi done fi done popd > /dev/null else echo "done." fi if [ $1 = "clean" ]; then echo "Please examine the contents of the following directories" echo "and delete anything that is no longer necessary" echo echo ${VHOST_HTDOCSDIR} echo ${VHOST_CGIBINDIR}/webmo echo ${VHOST_ROOT}/webmo fi