#!/bin/bash # ------- # File: lliurex-server-express # Description: Quick and dirty LliureX server configuration # Author: Luis Garcia Gisbert # # 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. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License along # with this program; if not, write to the Free Software Foundation, Inc., # 51 Franklin St, Fifth Floor, Boston MA 02110-1301 USA # -------- set -e ERROR_LOG="/tmp/error.express" PATH="/usr/sbin:/usr/bin:/sbin:/bin" LIB_FILE="/usr/share/lliurex-express/lliurex-express-common.sh" [ -r "$LIB_FILE" ] || exit 1 . $LIB_FILE # main # gettext hacks TEXTDOMAIN="lliurex-express" export TEXTDOMAIN [ -z "$LANG" ] || LANGUAGE="${LANG}:${LANGUAGE}" # some vars MSG_TITLE="$(gettext "LliureX Express")" MSG_REMAIN_DEPENDENCES="$(gettext "Remain this Dependence to execute this Program: ")" test_root # main # read data from scripts: SCR_EN (tests) and ZEN_STR (message) i=1 ZEN_STR="" for f in $(get_scripts) ; do ZEN_STR="$ZEN_STR\n$i\n\"$($f message)\"\n\"$($f status)\"" SCR_EN[$i]="$f" && ((i++)) done # Assure there are pending tasks [ ${#SCR_EN[@]} = 0 ] && error_msg "$(gettext "No pending tasks to configure")" && exit 1 ZEN_STR="$ZEN_STR\n$((${#SCR_EN[@]}+1))\n\"$(gettext "Exit")\"" OPT=$(echo -e $ZEN_STR |xargs zenity --height=300 --width=450 --title "$MSG_TITLE" --list --text "$(gettext "Tasks configuration to complete")" \ --hide-column=1 --column "$(gettext "Option")" --column "$(gettext "Description")" --column "$(gettext "Status")") # Run the selected option # if none selected re-run #echo ECHO:$ZEN_STR [ "x$OPT" = "x" ] && exec $0 # If it's not the last option (exit) exec the selected script and show the menĂº again. #echo "[ $OPT != $((${#SCR_EN[@]}+1)) ] && ${SCR_EN[$OPT]} prereqs && ${SCR_EN[$OPT]} exec && exec $0 " [ $OPT = $((${#SCR_EN[@]}+1)) ] && exit 0 rc=0 ${SCR_EN[$OPT]} prereqs || rc=$? if [ $rc -eq 0 ]; then ${SCR_EN[$OPT]} exec || zenity --info --text "$MSG_ERROR_CALL_PROCESS ${SCR_EN[$OPT]}" exec $0 else zenity --info --text "$MSG_REMAIN_DEPENDENCES $(cat $ERROR_LOG)" :> $ERROR_LOG exec $0 fi rm -f $ERROR_LOG