From 6d4591f6854851d018d2299e99ca15e6b8cd2297 Mon Sep 17 00:00:00 2001 From: Dennis Schwerdel Date: Mon, 5 Apr 2021 16:55:09 +0000 Subject: [PATCH] Install .target file --- .rpm/vpncloud.spec | 1 + CHANGELOG.md | 1 + Cargo.toml | 1 + src/installer.rs | 6 ++++++ 4 files changed, 9 insertions(+) diff --git a/.rpm/vpncloud.spec b/.rpm/vpncloud.spec index 2dbdc77..22ead41 100644 --- a/.rpm/vpncloud.spec +++ b/.rpm/vpncloud.spec @@ -28,6 +28,7 @@ mkdir -p %{buildroot}/lib/systemd/system mkdir -p %{buildroot}/usr/share/man/man1 cp %{buildroot}/../../../../../assets/example.net.disabled %{buildroot}/etc/vpncloud/example.net.disabled cp %{buildroot}/../../../../../assets/vpncloud@.service %{buildroot}/lib/systemd/system/vpncloud@.service +cp %{buildroot}/../../../../../assets/vpncloud.target %{buildroot}/lib/systemd/system/vpncloud.target cp %{buildroot}/../../../../../assets/vpncloud-wsproxy.service %{buildroot}/lib/systemd/system/vpncloud-wsproxy.service cp %{buildroot}/../../../../../target/vpncloud.1.gz %{buildroot}/usr/share/man/man1/vpncloud.1.gz cp -a * %{buildroot} diff --git a/CHANGELOG.md b/CHANGELOG.md index 4e63562..5dd3174 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ This project follows [semantic versioning](http://semver.org). ### UNRELEASED +- [added] Service target file (thanks to mnhauke) - [added] Added interactive configuration wizard - [added] Support for (un-)installation - [added] Building static binaries diff --git a/Cargo.toml b/Cargo.toml index 6077406..9ff0d23 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -83,6 +83,7 @@ assets = [ ["target/release/vpncloud", "/usr/bin/vpncloud", "755"], ["assets/example.net.disabled", "/etc/vpncloud/example.net.disabled", "600"], ["assets/vpncloud@.service", "/lib/systemd/system/vpncloud@.service", "644"], + ["assets/vpncloud.target", "/lib/systemd/system/vpncloud.target", "644"], ["assets/vpncloud-wsproxy.service", "/lib/systemd/system/vpncloud-wsproxy.service", "644"], ["target/vpncloud.1.gz", "/usr/share/man/man1/vpncloud.1.gz", "644"] ] diff --git a/src/installer.rs b/src/installer.rs index 184d025..97b3a9c 100644 --- a/src/installer.rs +++ b/src/installer.rs @@ -9,6 +9,7 @@ use std::{ const MANPAGE: &[u8] = include_bytes!("../target/vpncloud.1.gz"); const SERVICE_FILE: &[u8] = include_bytes!("../assets/vpncloud@.service"); +const TARGET_FILE: &[u8] = include_bytes!("../assets/vpncloud.target"); const WS_PROXY_SERVICE_FILE: &[u8] = include_bytes!("../assets/vpncloud-wsproxy.service"); const EXAMPLE_CONFIG: &[u8] = include_bytes!("../assets/example.net.disabled"); @@ -36,6 +37,9 @@ pub fn install() -> Result<(), Error> { File::create("/lib/systemd/system/vpncloud@.service") .and_then(|mut f| f.write_all(SERVICE_FILE)) .map_err(|e| Error::FileIo("Failed to create service file", e))?; + File::create("/lib/systemd/system/vpncloud.target") + .and_then(|mut f| f.write_all(TARGET_FILE)) + .map_err(|e| Error::FileIo("Failed to create service target file", e))?; File::create("/lib/systemd/system/vpncloud-wsproxy.service") .and_then(|mut f| f.write_all(WS_PROXY_SERVICE_FILE)) .map_err(|e| Error::FileIo("Failed to create wsporxy service file", e))?; @@ -49,6 +53,8 @@ pub fn uninstall() -> Result<(), Error> { fs::remove_file("/usr/share/man/man1/vpncloud.1.gz").map_err(|e| Error::FileIo("Failed to remove manpage", e))?; fs::remove_file("/lib/systemd/system/vpncloud@.service") .map_err(|e| Error::FileIo("Failed to remove service file", e))?; + fs::remove_file("/lib/systemd/system/vpncloud.target") + .map_err(|e| Error::FileIo("Failed to remove service target file", e))?; fs::remove_file("/lib/systemd/system/vpncloud-wsproxy.service") .map_err(|e| Error::FileIo("Failed to remove wsproxy service file", e))?; fs::remove_file("/usr/bin/vpncloud").map_err(|e| Error::FileIo("Failed to remove binary", e))?;