wip
This commit is contained in:
parent
a6f3653f33
commit
277de6f817
2 changed files with 21 additions and 57 deletions
31
unbox.sh
31
unbox.sh
|
@ -65,6 +65,27 @@ function unbox_inner_stage(){
|
|||
}
|
||||
|
||||
cd $(dirname $0)
|
||||
|
||||
|
||||
function test_fun(){
|
||||
#choose_one test1 | prefix_time
|
||||
#sleep 1
|
||||
#block_devices | choose_one -
|
||||
#echo "> "$test
|
||||
choose_dialog
|
||||
#sleep 1
|
||||
#choose_one | prefix_time
|
||||
}
|
||||
|
||||
if [ $# -eq 1 ]; then
|
||||
if [ $1 = "test" ]; then
|
||||
test_fun
|
||||
exit 0
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
|
||||
if [[ $# -ge 1 ]]; then
|
||||
CMD=$1
|
||||
shift
|
||||
|
@ -79,15 +100,5 @@ else
|
|||
$0 unbox_outer_stage
|
||||
fi
|
||||
|
||||
exit 0
|
||||
|
||||
|
||||
|
||||
type -t ls
|
||||
echo $?
|
||||
type -t echo
|
||||
echo $?
|
||||
type -t third_stage
|
||||
echo $?
|
||||
|
||||
|
||||
|
|
47
utils.sh
47
utils.sh
|
@ -12,53 +12,6 @@ function one_token_per_line(){
|
|||
done
|
||||
}
|
||||
|
||||
function choose_one(){
|
||||
if [ $# -eq 0 ]; then
|
||||
echo missing argument 1>&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ "$1" = "-" ]; then
|
||||
touch internal_pipe
|
||||
CNT=0
|
||||
tee internal_pipe | while read LINE; do
|
||||
CNT=$(($CNT+1))
|
||||
echo " "$CNT" > "$LINE
|
||||
done
|
||||
read -p "enter a number: " -u 1 NUM
|
||||
CNT=$(cat internal_pipe | wc -l)
|
||||
if [ "" = $NUM ]; then echo empty input; exit 1; fi
|
||||
if [ 0 -ge $NUM ]; then echo too small; exit 1; fi
|
||||
if [ $CNT -lt $NUM ]; then echo too large; exit 1; fi
|
||||
cat internal_pipe | head -n +$NUM | tail -n +$NUM
|
||||
rm internal_pipe
|
||||
else
|
||||
cat $1 | choose_one -
|
||||
fi
|
||||
}
|
||||
|
||||
function choose_dialog(){
|
||||
|
||||
: ${DIALOG:=dialog}
|
||||
OPTS="$OPTS --cr-wrap"
|
||||
high=10
|
||||
|
||||
rows=$(stty size | cut -d' ' -f1)
|
||||
[ -z "$rows" ] && rows=$high
|
||||
[ $rows -gt $high ] && rows=$high
|
||||
cols=$(stty size | cut -d' ' -f2)
|
||||
#$DIALOG --backtitle "Package configuration" \
|
||||
# --title "Configuring sun-java6-jre" \
|
||||
# $OPTS \
|
||||
# --yesno '\nIn order to install this package, you must accept the license terms, the "Operating System Distributor License for Java" (DLJ), v1.1. Not accepting will cancel the installation.\n\nDo you accept the DLJ license terms?' $rows $((cols - 5))
|
||||
|
||||
$DIALOG --backtitle "Package configuration" \
|
||||
--title "Configuring sun-java6-jre" \
|
||||
$OPTS \
|
||||
--menu '\nfoo bar?' $rows $((cols - 5)) 8 foo 1 bar 3 bat 3
|
||||
|
||||
}
|
||||
|
||||
function block_devices(){
|
||||
#lsblk -fPpo NAME,FSTYPE,LABEL,UUID,FSAVAIL,MOUNTPOINT
|
||||
lsblk -frpno NAME
|
||||
|
|
Loading…
Reference in a new issue