#!/bin/bash
# fuqiyang 2019-07-31
# https://pearid.webrtc.win/v1/mac_addr	--> auto generate mac
# watch -n 1 -d "cat /proc/net/dev | grep ppp"
#
image_name=3f6d59de90d9

name=(
tencent_sv_0
tencent_sv_1
tencent_sv_2
tencent_sv_3
tencent_sv_4
tencent_sv_5
tencent_sv_6
tencent_sv_7
tencent_sv_8
tencent_sv_9
tencent_sv_10
tencent_sv_11
tencent_sv_12
tencent_sv_13
tencent_sv_14
tencent_sv_15
tencent_sv_16
tencent_sv_17
tencent_sv_18
tencent_sv_19
tencent_sv_20
tencent_sv_21
tencent_sv_22
tencent_sv_23
tencent_sv_24
tencent_sv_25
tencent_sv_26
tencent_sv_27
tencent_sv_28
tencent_sv_29
tencent_sv_30
tencent_sv_31
tencent_sv_32
tencent_sv_33
tencent_sv_34
tencent_sv_35
tencent_sv_36
tencent_sv_37
tencent_sv_38
tencent_sv_39
tencent_sv_40
tencent_sv_41
tencent_sv_42
tencent_sv_43
tencent_sv_44
tencent_sv_45
tencent_sv_46
tencent_sv_47
tencent_sv_48
tencent_sv_49
tencent_sv_50
tencent_sv_51
tencent_sv_52
tencent_sv_53
tencent_sv_54
tencent_sv_55
tencent_sv_56
tencent_sv_57
tencent_sv_58
tencent_sv_59
tencent_sv_60
tencent_sv_61
tencent_sv_62
tencent_sv_63
tencent_sv_64
tencent_sv_65
tencent_sv_66
tencent_sv_67
tencent_sv_68
tencent_sv_69
tencent_sv_70
tencent_sv_71
tencent_sv_72
tencent_sv_73
tencent_sv_74
tencent_sv_75
tencent_sv_76
tencent_sv_77
tencent_sv_78
tencent_sv_79
tencent_sv_80
tencent_sv_81
tencent_sv_82
tencent_sv_83
tencent_sv_84
tencent_sv_85
tencent_sv_86
tencent_sv_87
tencent_sv_88
tencent_sv_89
tencent_sv_90
tencent_sv_91
tencent_sv_92
tencent_sv_93
tencent_sv_94
tencent_sv_95
tencent_sv_96
tencent_sv_97
tencent_sv_98
tencent_sv_99
)

nic=(
ppp0
ppp1
ppp2
ppp3
ppp4
ppp5
ppp6
ppp7
ppp8
ppp9
ppp10
ppp11
ppp12
ppp13
ppp14
ppp15
ppp16
ppp17
ppp18
ppp19
ppp20
ppp21
ppp22
ppp23
ppp24
ppp25
ppp26
ppp27
ppp28
ppp29
ppp30
ppp31
ppp32
ppp33
ppp34
ppp35
ppp36
ppp37
ppp38
ppp39
ppp40
ppp41
ppp42
ppp43
ppp44
ppp45
ppp46
ppp47
ppp48
ppp49
ppp50
ppp51
ppp52
ppp53
ppp54
ppp55
ppp56
ppp57
ppp58
ppp59
ppp60
ppp61
ppp62
ppp63
ppp64
ppp65
ppp66
ppp67
ppp68
ppp69
ppp70
ppp71
ppp72
ppp73
ppp74
ppp75
ppp76
ppp77
ppp78
ppp79
ppp80
ppp81
ppp82
ppp83
ppp84
ppp85
ppp86
ppp87
ppp88
ppp89
ppp90
ppp91
ppp92
ppp93
ppp94
ppp95
ppp96
ppp97
ppp98
ppp99
)

mac=(
00:00:d8:9c:e9:92
00:00:d8:98:01:b9
00:00:d8:10:06:f7
00:00:d8:54:69:59
00:00:d8:a0:3f:0a
00:04:ac:73:12:39
00:04:ac:76:15:ca
00:10:d7:c6:7b:18
00:04:ac:f7:b4:e0
00:10:d7:d6:17:4e
00:04:ac:fc:3e:7a
00:04:ac:d7:54:f5
00:04:ac:20:ff:02
00:10:d7:0c:e7:1f
00:04:ac:a7:b0:29
00:04:ac:78:f8:a6
00:00:d8:db:4a:d5
00:10:d7:01:d6:c2
00:10:d7:ac:55:27
00:04:ac:df:a1:d8
00:04:ac:41:b1:fb
00:00:d8:86:d9:67
00:00:d8:30:df:83
00:00:d8:b9:ce:c4
00:10:d7:56:dc:1e
00:04:ac:0f:98:15
00:04:ac:48:e7:fa
00:04:ac:6e:b8:ba
00:00:d8:65:cb:80
00:04:ac:13:39:77
00:04:ac:75:43:a5
00:00:d8:23:19:f9
00:04:ac:a7:cc:48
00:04:ac:bd:9c:66
00:04:ac:97:d5:82
00:04:ac:94:f7:6f
00:10:d7:15:94:13
00:00:d8:72:55:4e
00:10:d7:ec:7a:be
00:04:ac:91:78:5d
00:10:d7:8b:1e:fb
00:10:d7:f2:1c:b9
00:10:d7:02:a4:9e
00:00:d8:0b:1e:c1
00:00:d8:5e:9c:5f
00:00:d8:c8:43:ae
00:00:d8:df:34:ba
00:04:ac:cd:c5:0c
00:10:d7:4c:18:df
00:10:d7:20:f9:a9
00:04:ac:10:20:7e
00:10:d7:06:cf:60
00:10:d7:c8:81:c2
00:04:ac:ba:28:76
00:00:d8:4b:e0:7a
00:10:d7:6b:6e:11
00:04:ac:93:53:b6
00:10:d7:d7:ab:a8
00:10:d7:3e:ee:6e
00:04:ac:7f:68:08
00:04:ac:ad:ba:9f
00:00:d8:85:23:30
00:10:d7:4d:1c:54
00:04:ac:be:d2:e8
00:10:d7:61:46:0d
00:00:d8:49:c2:7d
00:10:d7:2f:3e:ee
00:04:ac:fa:7a:e3
00:00:d8:67:c4:da
00:00:d8:69:e4:75
00:10:d7:7b:43:22
00:00:d8:94:10:ee
00:00:d8:66:6b:08
00:00:d8:74:c4:bc
00:00:d8:64:47:c1
00:00:d8:d6:06:9a
00:10:d7:e5:dc:c6
00:10:d7:cd:31:e8
00:10:d7:a4:f6:28
00:00:d8:08:d9:6a
00:10:d7:53:2d:1a
00:10:d7:dd:de:bc
00:00:d8:83:b1:46
00:10:d7:bb:cd:12
00:10:d7:37:8f:f5
00:04:ac:02:b5:da
00:00:d8:ed:40:85
00:04:ac:26:00:39
00:00:d8:ba:a1:29
00:04:ac:af:1f:53
00:10:d7:fe:19:95
00:04:ac:e8:2b:e8
00:10:d7:bb:51:eb
00:10:d7:41:b4:78
00:04:ac:b7:76:81
00:04:ac:46:4c:c3
00:04:ac:ec:da:48
00:10:d7:5d:60:3b
00:04:ac:b4:5b:19
00:10:d7:0d:5c:60
)

disk=(
/sata0/openfogos/tencent_sv
/sata1/openfogos/tencent_sv
/sata2/openfogos/tencent_sv
/sata3/openfogos/tencent_sv
/sata4/openfogos/tencent_sv
/sata5/openfogos/tencent_sv
/sata6/openfogos/tencent_sv
/sata7/openfogos/tencent_sv
/sata8/openfogos/tencent_sv
/sata9/openfogos/tencent_sv
/sata10/openfogos/tencent_sv
/sata11/openfogos/tencent_sv
/sata12/openfogos/tencent_sv
/sata13/openfogos/tencent_sv
/sata14/openfogos/tencent_sv
/sata15/openfogos/tencent_sv
/sata16/openfogos/tencent_sv
/sata17/openfogos/tencent_sv
/sata18/openfogos/tencent_sv
/sata19/openfogos/tencent_sv
/sata20/openfogos/tencent_sv
/sata21/openfogos/tencent_sv
/sata22/openfogos/tencent_sv
/sata23/openfogos/tencent_sv
/sata24/openfogos/tencent_sv
/sata25/openfogos/tencent_sv
/sata26/openfogos/tencent_sv
/sata27/openfogos/tencent_sv
/sata28/openfogos/tencent_sv
/sata29/openfogos/tencent_sv
/sata30/openfogos/tencent_sv
/sata31/openfogos/tencent_sv
/sata32/openfogos/tencent_sv
/sata33/openfogos/tencent_sv
/sata34/openfogos/tencent_sv
/sata35/openfogos/tencent_sv
/sata36/openfogos/tencent_sv
/sata37/openfogos/tencent_sv
/sata38/openfogos/tencent_sv
/sata39/openfogos/tencent_sv
/sata40/openfogos/tencent_sv
/sata41/openfogos/tencent_sv
/sata42/openfogos/tencent_sv
/sata43/openfogos/tencent_sv
/sata44/openfogos/tencent_sv
/sata45/openfogos/tencent_sv
/sata46/openfogos/tencent_sv
/sata47/openfogos/tencent_sv
/sata48/openfogos/tencent_sv
/sata49/openfogos/tencent_sv
/sata50/openfogos/tencent_sv
/sata51/openfogos/tencent_sv
/sata52/openfogos/tencent_sv
/sata53/openfogos/tencent_sv
/sata54/openfogos/tencent_sv
/sata55/openfogos/tencent_sv
/sata56/openfogos/tencent_sv
/sata57/openfogos/tencent_sv
/sata58/openfogos/tencent_sv
/sata59/openfogos/tencent_sv
/sata60/openfogos/tencent_sv
/sata61/openfogos/tencent_sv
/sata62/openfogos/tencent_sv
/sata63/openfogos/tencent_sv
/sata64/openfogos/tencent_sv
/sata65/openfogos/tencent_sv
/sata66/openfogos/tencent_sv
/sata67/openfogos/tencent_sv
/sata68/openfogos/tencent_sv
/sata69/openfogos/tencent_sv
/sata70/openfogos/tencent_sv
/sata71/openfogos/tencent_sv
/sata72/openfogos/tencent_sv
/sata73/openfogos/tencent_sv
/sata74/openfogos/tencent_sv
/sata75/openfogos/tencent_sv
/sata76/openfogos/tencent_sv
/sata77/openfogos/tencent_sv
/sata78/openfogos/tencent_sv
/sata79/openfogos/tencent_sv
/sata80/openfogos/tencent_sv
/sata81/openfogos/tencent_sv
/sata82/openfogos/tencent_sv
/sata83/openfogos/tencent_sv
/sata84/openfogos/tencent_sv
/sata85/openfogos/tencent_sv
/sata86/openfogos/tencent_sv
/sata87/openfogos/tencent_sv
/sata88/openfogos/tencent_sv
/sata89/openfogos/tencent_sv
/sata90/openfogos/tencent_sv
/sata91/openfogos/tencent_sv
/sata92/openfogos/tencent_sv
/sata93/openfogos/tencent_sv
/sata94/openfogos/tencent_sv
/sata95/openfogos/tencent_sv
/sata96/openfogos/tencent_sv
/sata97/openfogos/tencent_sv
/sata98/openfogos/tencent_sv
/sata99/openfogos/tencent_sv
)

aa=""

for ((i=0; i<${#name[*]};i=i+1))
#for ((i=0; i<1;i=i+1))
do
	# debug
	#
	#echo "i = $i, name = ${name[$i]}, nic = ${nic[$i]}, mac = ${mac[$i]}, disk = ${disk[$i]}"
	#echo "docker run --name ${name[$i]} --restart=unless-stopped --cap-add=SYS_PTRACE --privileged=true --net=host --cpuset-cpus=${i} --env CPUS=${i} --env MAC=${mac[$i]} --env NIC=${nic[$i]} -v ${disk[i]}:/lego/extern -v /etc/localtime:/etc/localtime -d $image_name"

	# create docker
	#
	#mkdir -p ${disk[$i]}
	#docker run --name ${name[$i]} --restart=unless-stopped --cap-add=SYS_PTRACE --privileged=true --net=host --cpuset-cpus=${i} --env CPUS=${i} --env MAC=${mac[$i]} --env NIC=${nic[$i]} -v ${disk[i]}:/lego/extern -v /etc/localtime:/etc/localtime -d $image_name

	## run docker
	##
	#docker start ${name[$i]}

	# delete docker
	#
	#echo "stop ${name[$i]}"
	#docker stop ${name[$i]}
	#docker rm ${name[$i]}
	aa="${aa} ${name[$i]}_v018"
done
echo "${aa}"
docker stop ${aa}
docker rm ${aa}




