#!/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:04:ac:40:e5:90
00:10:d7:d2:51:32
00:00:d8:f9:71:6d
00:04:ac:cf:10:d4
00:10:d7:42:50:88
00:00:d8:82:ed:6f
00:00:d8:cb:6c:cb
00:10:d7:79:00:ea
00:00:d8:24:b6:3b
00:04:ac:d7:61:c9
00:00:d8:2f:7f:d9
00:00:d8:e6:87:65
00:10:d7:1f:67:dc
00:04:ac:ef:bc:e5
00:10:d7:35:3e:5e
00:00:d8:ae:a8:0f
00:00:d8:08:a2:e7
00:10:d7:3d:2f:8a
00:10:d7:16:5b:0a
00:04:ac:86:5b:92
00:10:d7:ae:17:26
00:10:d7:1a:1a:ef
00:10:d7:53:b1:07
00:00:d8:27:f9:fc
00:04:ac:4b:53:e3
00:04:ac:22:a9:a0
00:10:d7:d6:cd:32
00:00:d8:b4:61:66
00:10:d7:41:80:8a
00:04:ac:c9:2e:d7
00:04:ac:25:4f:36
00:00:d8:f7:fd:f8
00:04:ac:8e:15:98
00:04:ac:50:f8:54
00:10:d7:36:7c:40
00:00:d8:87:5d:17
00:04:ac:f9:6e:eb
00:10:d7:be:4f:5d
00:04:ac:37:6f:91
00:10:d7:40:8a:9a
00:04:ac:92:ff:1b
00:00:d8:d9:1c:ca
00:00:d8:3f:c9:82
00:10:d7:db:8c:a4
00:00:d8:be:db:7e
00:00:d8:76:80:9a
00:04:ac:11:e6:eb
00:10:d7:1e:e1:1f
00:00:d8:f0:0e:96
00:04:ac:9a:78:58
00:04:ac:25:07:b9
00:10:d7:d2:38:18
00:04:ac:d2:90:5b
00:04:ac:1c:8a:7d
00:04:ac:fa:54:6c
00:10:d7:e9:35:fa
00:00:d8:36:f3:2a
00:04:ac:e9:46:15
00:00:d8:ea:55:63
00:10:d7:72:a4:44
00:04:ac:88:38:fd
00:04:ac:11:b3:7b
00:04:ac:c3:63:db
00:00:d8:09:23:87
00:04:ac:47:0c:0d
00:00:d8:ad:07:21
00:00:d8:01:bd:ba
00:00:d8:44:64:bf
00:00:d8:46:68:26
00:00:d8:77:5c:a8
00:00:d8:0b:a4:06
00:00:d8:c5:56:90
00:00:d8:00:7c:3d
00:00:d8:e1:e5:3c
00:10:d7:6c:99:d2
00:00:d8:e7:10:06
00:04:ac:7f:28:69
00:10:d7:ec:8f:cc
00:10:d7:1f:01:81
00:04:ac:37:12:48
00:04:ac:7d:5b:d4
00:04:ac:31:74:2f
00:00:d8:b0:cc:7a
00:00:d8:6d:a0:99
00:10:d7:b9:40:39
00:10:d7:4c:40:0b
00:04:ac:58:fc:13
00:04:ac:de:28:74
00:10:d7:da:90:27
00:00:d8:85:f4:25
00:04:ac:eb:1b:0b
00:00:d8:2a:f1:93
00:10:d7:fa:c0:aa
00:04:ac:68:1f:93
00:04:ac:82:2f:5c
00:10:d7:eb:3e:b9
00:04:ac:50:fd:c7
00:10:d7:60:3d:a2
00:04:ac:d8:18:b5
00:04:ac:de:15:bb
)

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




