@@ -34,7 +34,9 @@ parse_args() {
3434 shift 2
3535 ;;
3636 -s | --data-sector-counts)
37- data_sector_counts=" $2 "
37+ _data_sector_counts=" $2 "
38+ IFS=' ,' read -r -a arr <<< " $_data_sector_counts"
39+ data_sector_counts=(" ${arr[@]} " )
3840 shift 2
3941 ;;
4042 --)
@@ -53,15 +55,15 @@ parse_args() {
5355 exit 100
5456 fi
5557
56- if [[ -z " ${data_sector_counts} " ]]; then
58+ if [[ -z " ${data_sector_counts[*] } " ]]; then
5759 echo " Need -s/--data-sector-counts"
5860 exit 100
5961 fi
6062
6163 UUID=" 8a3219d0-4002-4cd9-8cb1-f3ffe52451f1"
6264
6365 echo " INFO: PODMAN API LISTEN PORT: ${podman_port} "
64- echo " INFO: DATA SECTOR SIZE: ${data_sector_counts} "
66+ echo " INFO: DATA SECTOR SIZE: ${data_sector_counts[*] } "
6567 echo " INFO: BLOCK UUID=${UUID} "
6668}
6769
@@ -82,7 +84,7 @@ func_kill_ovmd() {
8284func_kill_service () {
8385 openrc stop_all
8486 while true ; do
85- ps aux | grep -v grep | grep ' podman --log-level=' > /dev/null
87+ ps aux | grep -v grep | grep ' podman --log-level=' > /dev/null
8688 ret=$?
8789 test $ret -eq 0 && echo " Killing podman api..." || {
8890 echo " Podman api stoped"
@@ -101,20 +103,21 @@ func_kill_service() {
101103# If find right disk, export BLKNAME
102104# find_disk have no outcall
103105find_disk () {
104- data_sector_counts=$1
105- block_with_sector_counts=$( find /sys/block/* /size -type f)
106- for blk in ${block_with_sector_counts} ; do
107- sector_counts=" $( < ${blk} ) "
108- blkname=$( dirname ${blk} )
109- if [[ " ${data_sector_counts} " = " ${sector_counts} " ]]; then
110- BLKNAME=$( basename ${blkname} ) # BLKNAME is target block !!
106+ local data_sector_counts=(" $@ " )
107+ for scnums in " ${data_sector_counts[@]} " ; do
108+ BLKNAME=$( grep -l -w " $scnums " /sys/block/* /size)
109+ if [[ -n " $BLKNAME " ]]; then
110+ echo " $BLKNAME :$scnums "
111+ BLKNAME=" $( basename " $( dirname " $( grep -l -w " $scnums " /sys/block/* /size) " ) " ) "
111112 BLKNAME=" /dev/$BLKNAME "
112- echo " find_disk(): Data block is $BLKNAME , Sector count $data_sector_counts "
113+ echo " find $BLKNAME with $scnums "
113114 return
115+ else
116+ echo " can not find block with $scnums , try again"
114117 fi
115118 done
116119
117- echo " find_disk(): No block with sector counts: ${data_sector_counts} "
120+ echo " find_disk(): No block with sector counts: ${data_sector_counts[*] } "
118121 exit 100
119122}
120123# mount ${BLKNAME} to ${mountpoint}
@@ -235,7 +238,7 @@ write_podman_config() {
235238main () {
236239 parse_args " $@ "
237240 func_kill_ovmd
238- find_disk ${data_sector_counts}
241+ find_disk " ${data_sector_counts[@]} "
239242 disk_format ${UUID}
240243
241244 # Copy /var/* into ${BLKNAME}
0 commit comments