Last active
March 23, 2020 07:32
-
-
Save m-motawea/159ccaaa5d45b126c8b9c033abe56bc8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from Jumpscale import j | |
| builder_method = j.baseclasses.builder_method | |
| class BuilderKeepalived(j.baseclasses.builder): | |
| __jslocation__ = "j.builders.network.keepalived" | |
| def _init(self, **kwargs): | |
| self.BUILDDIR = self._replace("{DIR_VAR}/build/keepalived") | |
| self.CODEDIR = self._replace("{DIR_CODE}") | |
| self.INSTALL_PATH = self._replace("{DIR_BIN}") | |
| self.CFG_PATH = "/sandbox/cfg/keepalived" | |
| self.VERSION = "2.0.18" | |
| @builder_method() | |
| def build(self): | |
| """ | |
| kosoms 'j.builders.network.keepalived.build()' | |
| """ | |
| deps = """ | |
| gcc libssl-dev libnl-3-dev libnl-genl-3-dev libsnmp-dev | |
| """ | |
| j.builders.system.package.ensure(deps) | |
| self._run("cd {DIR_TEMP}; wget -c http://keepalived.org/software/keepalived-%s.tar.gz" % self.VERSION) | |
| self._run("cd {DIR_TEMP}; tar -xzf keepalived-%s.tar.gz -C {CODEDIR}/" % self.VERSION) | |
| self._run("cd {CODEDIR}/keepalived-%s; ./configure --prefix=%s/keepalived-%s" % (self.VERSION, self.BUILDDIR, self.VERSION)) | |
| self._run("cd {CODEDIR}/keepalived-%s;make" % self.VERSION) | |
| self._run("cd {CODEDIR}/keepalived-%s;make install" % self.VERSION) | |
| @builder_method() | |
| def install(self): | |
| self._run("cp {CODEDIR}/keepalived-%s/keepalived/keepalived %s" % (self.VERSION, self.INSTALL_PATH)) | |
| def clean(self): | |
| self._run("rm -rf %s/keepalived" % self.INSTALL_PATH) | |
| self._run("rm -rf {CODEDIR}/keepalived-%s" % self.VERSION) | |
| self._run("rm -rf %s" % self.BUILDDIR) | |
| self._run("rm -f {DIR_TEMP}/keepalived-%s.tar.gz" % self.VERSION) | |
| def reset(self): | |
| super().reset() | |
| self.clean() | |
| def _run(self, command): | |
| return j.sal.process.execute(self._replace(command)) | |
| @property | |
| def startup_cmds(self): | |
| cmd = self._replace("keepalived --use-file %s/keepalived.conf --dont-fork" % self.CFG_PATH) | |
| cmds = [j.servers.startupcmd.get(name=self._name, cmd_start=cmd)] | |
| return cmds | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from Jumpscale import j | |
| from JumpscaleBuilders.runtimes.BuilderGolangTools import BuilderGolangTools | |
| builder_method = j.baseclasses.builder_method | |
| class BuilderUdp6Proxy(BuilderGolangTools): | |
| __jslocation__ = "j.builders.network.udp6proxy" | |
| @builder_method() | |
| def _init(self, **kwargs): | |
| super()._init() | |
| self.DIR_UDP6PROXY = self.package_path_get("m-motawea/udp6proxy") | |
| @builder_method() | |
| def configure(self): | |
| pass | |
| @builder_method() | |
| def build(self): | |
| j.builders.runtimes.go.install() | |
| self.get("github.com/m-motawea/udp6proxy") | |
| self.profile.env_set("GO111MODULE", "on") | |
| build_cmd = """ | |
| cd {DIR_UDP6PROXY} | |
| go build . | |
| """ | |
| self._execute(build_cmd) | |
| @builder_method() | |
| def install(self): | |
| self._copy("{DIR_UDP6PROXY}/udp6proxy", "{DIR_BIN}") | |
| self._copy("{DIR_UDP6PROXY}/config.toml", "{DIR_BASE}/cfg/config.toml") | |
| @property | |
| def startup_cmds(self): | |
| proxy_cmd = self._replace("udp6proxy {DIR_BASE}/cfg/config.toml") | |
| proxy_startup = j.servers.startupcmd.get( | |
| "udp6proxy_startup", cmd_start=proxy_cmd, path=j.core.tools.text_replace("{DIR_BIN}") | |
| ) | |
| return [proxy_startup] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment