This repository has been archived by the owner on Jul 9, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmedia.java
71 lines (57 loc) · 2.52 KB
/
media.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
package profile;
import java.util.Vector;
import core.iface.IUnit;
import core.model.NetworkModel;
import core.model.ServerModel;
import core.profile.AStructuredProfile;
import core.unit.SimpleUnit;
import core.unit.fs.DirMountedUnit;
import core.unit.fs.DirUnit;
import core.unit.fs.FileAppendUnit;
public class media extends AStructuredProfile {
public media(ServerModel me, NetworkModel networkModel) {
super("media", me, networkModel);
}
public Vector<IUnit> getNetworking() {
Vector<IUnit> units = new Vector<IUnit>();
for (ServerModel router : networkModel.getRouterServers()) {
//DNAT
router.getFirewallModel().addNatPrerouting("dnat_media_ssh",
"-d " + networkModel.getData().getExternalIp("media_lb")
+ " -p tcp"
+ " --dport 31337"
+ " -j DNAT --to-destination " + me.getIP().getHostAddress() + ":" + networkModel.getData().getSSHPort(me.getLabel()),
"Redirect external traffic on :31337 to our Media server");
router.getFirewallModel().addFilter("media_ssh_ingress", "media_ingress",
"-s 178.238.149.157"
+ " -d " + networkModel.getServerModel(me.getLabel()).getIP().getHostAddress()
+ " -p tcp"
+ " --dport " + networkModel.getData().getSSHPort(me.getLabel())
+ " -j ACCEPT",
"Allow inbound SSH");
router.getFirewallModel().addFilter("media_ssh_egress", "media_egress",
"-d 178.238.149.157"
+ " -s " + me.getIP().getHostAddress()
+ " -p tcp"
+ " --sport " + networkModel.getData().getSSHPort(me.getLabel())
+ " -j ACCEPT",
"");
}
return units;
}
protected Vector<IUnit> getPersistentConfig() {
Vector<IUnit> units = new Vector<IUnit>();
units.addElement(new SimpleUnit("candc_user", "proceed",
"sudo useradd -m candc -c 'C&C Music Factory'",
"id candc 2>&1", "id: ‘candc’: no such user", "fail",
"The candc user couldn't be added."));
units.addElement(new DirUnit("tc_dir_exists", "is_virtualbox_guest", "/media/data/transcodeDir"));
//Mount /media/data/transcodeDir
units.addElement(new FileAppendUnit("tc_fstab", "is_virtualbox_guest", "transcodeDir /media/data/transcodeDir vboxsf defaults,_netdev,uid=$(id candc -u),gid=$(id candc -g) 0 0", "/etc/fstab",
"Couldn't create the mount for transcoding at /media/data/transcodeDir"));
units.addElement(new DirUnit("tc_bindpoint", "is_virtualbox_guest", "/media/data/transcodeDir"));
units.addElement(new DirMountedUnit("tc", "tc_fstab_appended", "transcodeDir",
"Couldn't mount the transcoding directory."));
return units;
}
}