# $Id$ # install plugins is_installed() { local i local item="$1" for i in ${SETTINGSPATH}/plugins/* do [[ $(basename ${i}) = ${item} ]] && return 1 done return 0 } config_plugins() { local all_ids local installed_plugins local i local plugin local keep # install needed directories [[ ! -d ${SETTINGSPATH}/plugins ]] && install -d ${SETTINGSPATH}/plugins # get all ids all_ids=$(mysqldo "select id from cfg_plugins where serial='${ALX_SERIAL}'") # install for i in ${all_ids} do evaluate_table cfg_plugins "where serial='${ALX_SERIAL}' and id='${i}'" # install only if not already installed if [[ -x ${ALX_PLUGINS}/${cfg_plugins_plugin}/plugin.sh ]] && [[ ! -f ${SETTINGSPATH}/plugins/${cfg_plugins_plugin} ]] then rc_echo " Installing plugin '${cfg_plugins_plugin}' ..." ${ALX_PLUGINS}/${cfg_plugins_plugin}/plugin.sh install touch ${SETTINGSPATH}/plugins/${cfg_plugins_plugin} fi # always run plugin setup on every boot to honor any changes if [[ -x ${ALX_PLUGINS}/${cfg_plugins_plugin}/plugin.sh ]] then rc_echo " Setting up plugin '${cfg_plugins_plugin}' ..." ${ALX_PLUGINS}/${cfg_plugins_plugin}/plugin.sh setup fi done # uninstall if [ -d ${SETTINGSPATH}/plugins ] then installed_plugins=$(find ${SETTINGSPATH}/plugins -mindepth 1 -maxdepth 1 -type f -printf '%f\n') for plugin in ${installed_plugins} do keep=0 for i in ${all_ids} do evaluate_table cfg_plugins "where serial='${ALX_SERIAL}' and id='${i}'" if [[ ${plugin} = ${cfg_plugins_plugin} ]] then keep=1 # found, break here break fi done if [[ ${keep} = 0 ]] then rc_echo " Uninstalling plugin '${plugin}' ..." ${ALX_PLUGINS}/${plugin}/plugin.sh uninstall rm -f ${SETTINGSPATH}/plugins/${plugin} fi done fi }