#!/bin/bash -
##################################################
# This scripts is uesed to run PrimeTime,
# You could get help by type "run_pt.bash -h"
#################################################
# Function: Usage
Usage () {
echo "**************************************************" >&2
echo "[Usage] Below options are used:" >&2
echo "-h : Get this help description;" >&2
echo "-d : Run PrimeTime in Debug Mode;" >&2
echo "-l (1/0) : 1 -> Run PrimeTime on Local Machine;" >&2
echo " 0 -> Run PrimeTime on Server(Default);" >&2
echo "-f Constraints_file : Run PrimeTime in Debug Mode;" >&2
echo "-s Session_name : Run PrimeTime and restore the Session;" >&2
echo "(No option) : Run PrimeTime with your latest setting.\n" >&2
echo "Example: $0 -d" >&2
echo "Example: $0 -d -s Session" >&2
echo "**************************************************" >&2
exit
}
# *******************************************************
# Function Blocks
# *******************************************************
# Function: Pt_Local
#Pt_Local () {
#if test -h $1
#then
#cp $1 ${1}.old
#unlink $1
#mv ${1}.old $1
#printf "[Info]: %20s unlink done!!\n" $1
#else
#printf "[Info]: %20s isn't a link file!!\n" $1
#fi
#}
# Function: Pt_Server
#Pt_Server () {
#}
# Function: run_mac
#run_pt () {
#}
# Function: Resave_option
Resave_option () {
echo "File=$file" > .run_pt.option.log
echo "Debug=$debug" >> .run_pt.option.log
echo "Session=$session" >> .run_pt.option.log
#if test -h .run_pt.option.log
#then
#'rm .run_pt.option.log'
#'touch .run_pt.option'
#else
#echo "[Warning]Firsrt time run PrimeTime or lost the latest option setting" >&2
#echo "Please use more detailed options." >&2
#fi
}
# Function: Restore_option
Restore_option () {
while read line
do
tmp=${line#*=}
echo "$tmp"
#case $line in
#-f) file=$2
#shift 2
#;;
#-s | -session) session=$2
#shift 2
#;;
#-d) debug=1
#shift
#;;
#-h | -help) Usage
#exit 1
#;;
#-l) machine=$2
#shift 2
#;;
#--) shift
##break
#;;
#-*) echo $0:$1 : unrecognised option >&2
#shift
#;;
#esac
done < .run_pt.option.log
}
# Function: Option_check
# *******************************************************
# Main Process Begin Here
# *******************************************************
# Parameter Setting
file=
session=
debug=0
machine=0
if [[ $# = 0 && -e .run_pt.option.log ]]; then
echo "***********************************************" >&2
echo "[Info]: Use your latest setup to run PrimeTime;" >&2
echo "***********************************************" >&2
elif [[ $# = 0 ]]; then
echo "***********************************************" >&2
echo "[Warning]: No history Setting log, Pls refer below:" >&2
Usage
echo "***********************************************" >&2
fi
# Main Function
while [ $# -gt 0 ]
do
echo $#
case $1 in
-f) file=$2
shift 2
;;
-s | -session) session=$2
shift 2
;;
-d) debug=1
shift
;;
-h | -help) Usage
exit 1
;;
-l) machine=$2
shift 2
;;
--) shift
#break
;;
-*) echo $0:$1 : unrecognised option >&2
shift
;;
esac
done
Restore_option
Resave_option
exit
#echo $*
#for i in $*
#do
# if test -h $i
# then
# cp $i ${i}_1
# unlink $i
# mv ${i}_1 $i
# printf "[Info]: %20s unlink done!!\n" $i
# else
#
# printf "[Info]: %20s isn't a link file!!\n" $i
# fi
#done
#while [ $# -gt 0 ]
#do
# if test -h $i
# then
# ehco "$i"
# mv $i ${i}_1
# unlink $i
# mv ${i}_1 $i
# else
# echo "$i isn't a link!!"
# fi
# shift
#done