#!/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:5b:d1:d9
00:10:d7:0e:a7:13
00:10:d7:a9:d2:ab
00:10:d7:b3:81:ad
00:04:ac:db:5b:a3
00:00:d8:2e:ae:ea
00:00:d8:d5:80:1f
00:00:d8:71:6e:54
00:00:d8:63:4b:b9
00:04:ac:a2:2e:20
00:00:d8:e2:b3:55
00:04:ac:0e:0f:2d
00:10:d7:32:a9:76
00:10:d7:ef:f4:c9
00:04:ac:28:16:b4
00:10:d7:66:cf:7e
00:00:d8:d6:63:ed
00:04:ac:36:13:79
00:10:d7:5c:a2:f2
00:10:d7:30:89:2f
00:00:d8:d2:78:db
00:00:d8:f8:60:58
00:00:d8:46:f2:0e
00:04:ac:61:73:ef
00:10:d7:80:66:f0
00:00:d8:01:22:88
00:00:d8:36:6a:42
00:10:d7:17:d4:ea
00:04:ac:02:ec:ff
00:00:d8:8d:27:c2
00:04:ac:22:a2:cb
00:10:d7:bc:b8:ca
00:04:ac:75:b1:32
00:10:d7:5c:ba:c2
00:10:d7:57:11:c5
00:00:d8:5a:b1:fa
00:10:d7:45:11:05
00:04:ac:f1:f6:54
00:10:d7:5a:51:ea
00:10:d7:86:b8:69
00:00:d8:21:bd:a0
00:10:d7:d4:c0:83
00:10:d7:f2:fd:d5
00:04:ac:2e:bd:b6
00:00:d8:da:fb:09
00:04:ac:a4:10:96
00:04:ac:f8:75:35
00:00:d8:bd:0a:9d
00:04:ac:73:e5:13
00:00:d8:c9:4e:bb
00:10:d7:01:04:0e
00:04:ac:82:cb:6c
00:04:ac:31:97:10
00:10:d7:84:05:c6
00:04:ac:51:a3:94
00:04:ac:ac:eb:f9
00:04:ac:eb:d6:c0
00:04:ac:39:16:51
00:00:d8:29:45:be
00:00:d8:9b:78:f8
00:04:ac:5b:a9:5c
00:00:d8:0c:db:5e
00:00:d8:c5:92:b8
00:00:d8:30:96:e2
00:00:d8:ff:39:37
00:10:d7:90:3c:f2
00:10:d7:6c:67:b4
00:04:ac:ac:fe:e9
00:10:d7:b4:f4:d3
00:00:d8:89:bb:22
00:10:d7:c8:20:3c
00:04:ac:0f:ba:c1
00:10:d7:d0:f6:fb
00:10:d7:50:9f:2c
00:00:d8:c9:cb:41
00:10:d7:ee:12:fb
00:00:d8:ca:18:50
00:10:d7:ca:cc:a6
00:04:ac:86:cd:dc
00:10:d7:e7:56:1e
00:04:ac:93:b8:9b
00:10:d7:4d:db:f3
00:04:ac:73:2a:30
00:00:d8:cf:e8:ca
00:10:d7:d4:db:4c
00:10:d7:f4:02:6f
00:00:d8:46:42:72
00:00:d8:44:bd:ac
00:04:ac:8e:42:87
00:10:d7:82:4e:40
00:04:ac:f2:80:aa
00:00:d8:8c:39:3a
00:10:d7:22:9f:f4
00:00:d8:ba:a3:8a
00:10:d7:1a:3e:7e
00:00:d8:38:0d:14
00:10:d7:48:3e:1e
00:10:d7:da:90:99
00:04:ac:3b:96:90
00:04:ac:f5:2d:9b
)

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




