use of org.platformlayer.ops.filesystem.FilesystemAction in project platformlayer by platformlayer.
the class PersistIptablesScripts method addChildren.
@Override
protected void addChildren() throws OpsException {
addChild(ManagedDirectory.build(BASE_DIR, "0644"));
addChild(SimpleFile.build(getClass(), new File("/etc/network/if-pre-up.d/iptables-lockdown")).setFileMode("755").setUpdateAction(new FilesystemAction() {
@Override
public void execute(OpsTarget target, ManagedFilesystemItem managedFilesystemItem) throws OpsException {
if (managedFilesystemItem.getNewFileWasCreated()) {
// Set the parameters the ifup sets
CommandEnvironment env = new CommandEnvironment();
env.put("MODE", "start");
env.put("IFACE", "--all");
env.put("ADDRFAM", "meta");
Command runLockdown = Command.build("/etc/network/if-pre-up.d/iptables-lockdown");
runLockdown.setEnvironment(env);
target.executeCommand(runLockdown);
}
}
}));
addChild(SimpleFile.build(getClass(), new File("/etc/network/if-up.d/iptables-ifup")).setFileMode("755"));
}
Aggregations