#!/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:10:d7:3f:1e:7a
00:10:d7:f2:9e:a8
00:10:d7:10:65:59
00:00:d8:0f:fd:e5
00:04:ac:37:9e:c6
00:10:d7:fe:4e:75
00:10:d7:2b:e9:04
00:00:d8:64:1b:ed
00:04:ac:1f:80:21
00:00:d8:a6:f8:30
00:04:ac:e9:6e:62
00:10:d7:33:22:95
00:10:d7:76:a3:2c
00:04:ac:92:e4:2f
00:04:ac:3b:1a:df
00:04:ac:76:43:df
00:00:d8:82:b3:22
00:04:ac:a6:70:2a
00:10:d7:fd:f8:43
00:04:ac:b3:c8:9e
00:04:ac:cd:2d:98
00:00:d8:b6:ad:86
00:04:ac:7d:07:53
00:00:d8:67:ff:c4
00:04:ac:04:ad:d6
00:10:d7:e6:89:66
00:00:d8:85:a1:0c
00:04:ac:ed:38:a1
00:10:d7:52:df:2f
00:00:d8:ee:67:f4
00:04:ac:7c:3f:0d
00:00:d8:72:50:6a
00:04:ac:e7:0b:7d
00:10:d7:dd:59:32
00:00:d8:fc:eb:14
00:10:d7:ef:d1:d7
00:10:d7:dd:42:48
00:00:d8:65:91:c9
00:10:d7:e6:f6:3e
00:04:ac:91:a6:cd
00:04:ac:77:a2:29
00:10:d7:a9:3c:23
00:00:d8:ce:2c:97
00:04:ac:7e:70:a2
00:00:d8:61:84:d2
00:00:d8:30:28:f2
00:04:ac:48:b0:9e
00:04:ac:44:75:bc
00:00:d8:82:24:cb
00:00:d8:e7:23:df
00:10:d7:21:92:e0
00:00:d8:73:0b:c0
00:04:ac:40:4a:d7
00:00:d8:1a:82:17
00:04:ac:75:3b:e9
00:00:d8:89:5e:9c
00:00:d8:80:44:72
00:04:ac:41:cb:6d
00:00:d8:d4:ce:0f
00:00:d8:6d:98:27
00:10:d7:1c:6b:6f
00:10:d7:68:c2:c6
00:10:d7:05:d8:8c
00:10:d7:76:f2:f4
00:04:ac:11:6f:24
00:04:ac:82:42:94
00:00:d8:28:7b:0f
00:00:d8:2d:fa:d4
00:00:d8:64:c7:99
00:10:d7:a6:c7:d3
00:00:d8:1b:dc:74
00:00:d8:e2:ff:bb
00:10:d7:f2:ba:ff
00:04:ac:b9:64:6e
00:10:d7:5e:78:e0
00:10:d7:ff:75:2e
00:00:d8:96:bf:3f
00:10:d7:8f:6f:18
00:10:d7:f6:75:d2
00:10:d7:13:57:93
00:00:d8:9e:1a:22
00:00:d8:99:56:ec
00:10:d7:1c:67:10
00:10:d7:65:2b:72
00:04:ac:3e:3a:10
00:04:ac:f9:9c:5b
00:00:d8:0a:f3:8f
00:04:ac:8f:9d:1b
00:10:d7:75:ba:11
00:00:d8:85:d0:23
00:00:d8:71:91:8b
00:00:d8:b8:11:17
00:00:d8:40:d7:09
00:10:d7:5c:be:fe
00:00:d8:94:4c:ed
00:10:d7:e3:64:7c
00:00:d8:48:f6:ec
00:10:d7:33:31:c3
00:10:d7:7f:1b:3c
00:04:ac:ae:88:08
)

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
)

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]}
done




