Scripts

De OviWiki
Aller à : navigation, rechercher

install_addon.sh

Ce script permet d'installer un module dans Ovidentia en utilisant des liens symboliques. Cette méthode permet d'utiliser dans ovidentia un module en cours de développement et pouvant être directement utilisé par un outil de suivi du code source comme git ou cvs.

pour obtenir la liste des paramètres, utiliser ./install_addon.sh --help

<source lang="bash">

  1. !/bin/bash



copyDirectory() { echo -e "${BOLD}Copying${OFF} '${1}'" echo -e " => '${2}'" if [ -d "${1}" ] then if [ -h "${2}" ] then rm "${2}" else rm -R "${2}" fi cp -vR "${1}" "${2}" | grep addonini find "${2}" -name "CVS" -exec rm -R {} \; fi }


symlinkDirectory() { echo -e "${BOLD}Linking${OFF} '${1}'" echo -e " => '${2}'"


if [ -h "${2}" ] then rm "${2}" fi

ln -sf "${1}" "${2}" }


removeDirectory() { echo -e "${BOLD}Unlinking${OFF} '${2}'"

if [ -h "${2}" ] then rm "${2}" else if [ ! -d "${2}" ] then echo -e "****** ${BOLD}Directory does not exist${OFF}" return fi rm -R "${2}"; fi }


linkDirectory() { if [ "${INSTALL_MODE}" = "copy" ] then copyDirectory "${1}" "${2}" return fi

if [ "${INSTALL_MODE}" = "remove" ] then removeDirectory "${1}" "${2}" return fi

symlinkDirectory "${1}" "${2}" }


linkDirectories() { linkDirectory "${addonPath}/${addonName}/${addonSrc}" "${kernelSrc}/${addonName}" linkDirectory "${addonPath}/${addonName}/${addonTemplates}" "${kernelTemplates}/${addonName}" linkDirectory "${addonPath}/${addonName}/${addonOvml}" "${kernelOvml}/${addonName}" linkDirectory "${addonPath}/${addonName}/${addonLang}" "${kernelLang}/${addonName}" linkDirectory "${addonPath}/${addonName}/${addonStyles}" "${kernelStyles}/${addonName}" linkDirectory "${addonPath}/${addonName}/${addonImages}" "${kernelImages}/${addonName}" linkDirectory "${addonPath}/${addonName}/${addonTheme}" "${kernelTheme}/${addonName}" }


showUsage() { echo "" echo "install_addon.sh" echo " [-a|--addonpath=path/to/addon/dir] (default : ${defaultWorkspace})" echo " [-k|--kernelpath=path/to/kernel/dir] (default : ${defaultWorkspace}/ovidentia)" echo " [-s|--skinpath=path/to/skin/dir] (default : /var/www/ovhead/skins)" echo " [-m|--mode=(link|copy|remove)] (default : link)" echo " addon1 [addon2 ...]" echo "" }

listAddons() { echo -e "\nAddons in addons directory:\n" cd "${addonPath}" ls */programs/addonini.php 2> /dev/null | cut -d "/" -f 1 echo -e "\n"; }



if [ -d "${HOME}/sources" ] then defaultWorkspace="${HOME}/sources" elif [ -d "${HOME}/workspace" ] then defaultWorkspace="${HOME}/workspace" else defaultWorkspace="${HOME}" fi


BOLD=$(tput bold) OFF=$(tput sgr0)



TEMP=`getopt -o a:k:s:m: --long addonpath:,kernelpath:,skinpath:,mode:,help -- "$@"`

if [ $? != 0 ] then showUsage echo "Terminating..." >&2 exit 1 fi

eval set -- "$TEMP"

while true do case "$1" in -a|--addonpath) BAB_ADDON_PATH="$2" shift 2 ;; -k|--kernelpath) BAB_KERNEL_PATH="$2" shift 2 ;; -s|--skinpath) BAB_SKIN_PATH="$2" shift 2 ;; -m|--mode) INSTALL_MODE="$2" shift 2 ;; --help) showUsage exit 0 ;; --) shift break ;; -*) showUsage exit 1 ;;

esac done




addonPath="${BAB_ADDON_PATH:-${defaultWorkspace}}" kernelPath="${BAB_KERNEL_PATH:-${defaultWorkspace}/ovidentia}" skinPath="${BAB_SKIN_PATH:-/var/www/ovhead/skins}"

if [ ! -d "${addonPath}" ] then echo "${BOLD}Addonpath '${addonPath}' does not exists${OFF}" exit 1 fi

if [ ! -d "${kernelPath}" ] then echo "${BOLD}kernelPath '${kernelPath}' does not exists${OFF}" exit 1 fi


echo "Addon path: ${BOLD}${addonPath}${OFF}" echo "Kernel path: ${BOLD}${kernelPath}${OFF}" echo "Skins path: ${BOLD}${skinPath}${OFF}"

addonSrc="programs" addonImages="skins/ovidentia/images" addonTemplates="skins/ovidentia/templates" addonOvml="skins/ovidentia/ovml" addonStyles="styles" addonLang="langfiles" addonTheme="theme"

kernelRoot="${kernelPath}" kernelSrc="${kernelPath}/addons" kernelImages="${kernelPath}/${addonImages}/addons" kernelTemplates="${kernelPath}/${addonTemplates}/addons" kernelOvml="${kernelPath}/${addonOvml}/addons" kernelStyles="${kernelPath}/${addonStyles}/addons" kernelLang="${kernelPath}/lang/addons" kernelTheme="${skinPath}"


for addonName do addonRoot="${addonPath}/${addonName}" if [ ! -d "${addonRoot}" ] then echo "${BOLD}Addon '${addonName}' not present in ${addonPath}${OFF}" listAddons exit 1 fi done


for addonName do if [ "${INSTALL_MODE}" = "remove" ] then echo "${BOLD}Removing addon '${addonName}'${OFF}" else echo "${BOLD}Installing addon '${addonName}'${OFF}" fi

addonRoot="${addonPath}/${addonName}"

linkDirectories done


</source>