#!/bin/bashMODULE_NUM=1MODULE_MAX_NUM=5WORK_PATH=/root/shell/workspace#add moduleadd(){ installNum=$MODULE_NUM if [ -z $2 ]; then echo "install default number : $MODULE_NUM" else installNum=$2 fi if [ $installNum -gt $MODULE_MAX_NUM ]; then installNum=$MODULE_MAX_NUM fi echo "install number is $installNum" for i in $(seq 1 $installNum); do do_add $i done}#do the add operationdo_add(){ if [ ! -e $WORK_PATH/test$1 ]; then mkdir $WORK_PATH/test$1 echo "add test$1" fi}#do the remove operationdo_remove(){ if [ -d $WORK_PATH/test$1 ]; then echo "remove module $1" rm -rf $WORK_PATH/test$1 fi}#remove all modulesremove(){ #echo "remove all modules" for((i=1;i<=$MODULE_MAX_NUM;i++)); do if [ -e $WORK_PATH/test$i ]; then do_remove $i fi done}#modify modules numbermodify(){ modNum=$2 echo modify modules number to $2 for((i=$MODULE_MAX_NUM;i>$2;i--)); do #echo "remove module $i" do_remove $i done if [ $modNum -gt $MODULE_MAX_NUM ]; then modNum=$MODULE_MAX_NUM fi for((i=1;i<=$modNum;i++)); do #echo "add module $modNum" do_add $i done}#main processcase $1 inadd) add $1 $2;;rmv) remove $1;;mod) modify $1 $2;;*) echo -e "bad parameter, usage : balabala...";;esac