#!/bin/sh #---------------------------------------------------------------------------- # /var/install/bin/get-url - help script to get index.txt # # Creation: 2012-02-26 hbfl # Last Update: $Id$ # # Copyright (c) 2012-2012 the eisfair team, team(at)eisfair(dot)org # # 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. #---------------------------------------------------------------------------- # set package name package_name="url" # include config . /etc/config.d/${package_name} . /var/install/include/eislib #debug_get_url=true if ${debug_get_url:-false} then exec 2>/tmp/$(basename ${0})-trace$$.log set -x ask_debug=true export ask_debug fi gotoyx () { echo -e "\033[$1;$2H\c"; } url_file=/var/install/url ASK=/var/install/bin/ask idx=1 while [ ${idx} -le ${URL_N} ] do eval url_path='${URL_'${idx}'_PATH}' eval url_name='${URL_'${idx}'_NAME}' if [ -z "${_url_install}" ] then _url_install=${url_name}%${url_path} else _url_install=$(echo "${_url_install}";echo "${url_name}%${url_path}") fi idx=$(expr ${idx} + 1) done clrhome mecho --info "Install package from URL" echo mecho --stdbr " Available package sources:" echo techo --begin '3 4r 2 1 70*' idx=1 echo "${_url_install}" | while read line do # set IFS to : without techo line _OLD_IFS=${IFS} IFS='%' set -- ${line} IFS=${_OLD_IFS} _name="${1}" _url="${2}" if [ -n "${_name}" ] then _show_name="${_name}" else _show_name="${_url}" fi techo --row "" "${idx}." --link '>' "" "${_show_name}" idx=$(expr ${idx} + 1) done echo echo echo techo --end gotoyx `expr "${_EISLIB_SCREENSIZE_Y}" - 2` 1 echo line_count=$(expr 4 + $(echo "${_url_install}" | wc -l)) # set info line to screen is $_line_count + 2 -gt $LINES if [ ${_EISLIB_SCREENSIZE_Y} -lt `expr "${line_count}" + 2` ] then mecho --info "Use SHIFT + PAGE-UP to scroll up" else echo fi _ask_tmpfile=$(mktemp -t XXXXXXXXXXXXX) ${ASK} "Select" "" "1-$(echo "${_url_install}" | wc -l)" "^$=Return" "0=Exit" >${_ask_tmpfile} rc=${?} _selected_entry=$(cat ${_ask_tmpfile}) rm -f ${_ask_tmpfile} # if ask break, ask returned 255 if [ ${rc} = 255 ] then _selected_entry=0 fi case ${_selected_entry} in '') exit 0 ;; 0) exit 127 ;; *) # get action line _selected_project="$(echo "${_url_install}" | sed -n "${_selected_entry}p" | sed 's/^ *//')" # set IFS to : without techo line _OLD_IFS=${IFS} IFS='%' set -- ${_selected_project} IFS=${_OLD_IFS} _name="${1}" _url="${2}" echo "${_url}" > ${url_file} ;; esac /var/install/bin/install-package # --------------------------------------------------------------------------- # end # ---------------------------------------------------------------------------