Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: darwin release #19

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,16 @@ jobs:
for arch in amd64; do
mkdir -p build/package/rvpn_linux_$arch/{,bin/,systemd/}
cp build/client_linux_$arch build/package/rvpn_linux_$arch/bin/rvpn
cp -r support/systemd/ build/package/rvpn_linux_$arch/systemd/
cp -r support/systemd/ build/package/rvpn_linux_$arch/
tar --owner root --group root --sort name \
-C build/package/ -czvf rvpn_linux_$arch.tar.gz rvpn_linux_$arch
done
for arch in amd64 arm64; do
mkdir -p build/package/rvpn_darwin_$arch/{,bin/,systemd/}
cp build/client_darwin_$arch build/package/rvpn_darwin_$arch/bin/rvpn
cp -r support/launchd/ build/package/rvpn_darwin_$arch/
tar --owner root --group root --sort name \
-C build/package/ -czvf rvpn_darwin_$arch.tar.gz rvpn_darwin_$arch

- uses: softprops/action-gh-release@v1
with:
Expand Down
3 changes: 3 additions & 0 deletions cmd/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,9 @@ func ClientConnectProfile(profile string, opts common.ClientOptions) {
os.Exit(1)
}

// either receive message from connectEvent chan or timeout 5 seconds
// if connectEvent then test for connectivity by pinging the VPN server

fmt.Printf("rVPN successfully connected to profile %s\n", profile)
}

Expand Down
58 changes: 58 additions & 0 deletions support/install-darwin.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#!/bin/bash

set -euo pipefail

version="v0.0.1"
arch="amd64" # FIXME

err() {
echo "$@" >&2
}

main() {

# setup tempdir
tmpdir="$(mktemp -d)"
cd "$tmpdir"
cleanup() {
[ -z "$tmpdir" ] || rm -rf "$tmpdir"
}
trap cleanup EXIT

# detect sudo
if [ "$(id -u)" -eq 0 ]; then
sudo=''
elif command -v sudo >/dev/null; then
sudo=sudo
elif command -v doas >/dev/null; then
sudo=doas
else
err 'You must be root'
exit 1
fi

# download tar
curl -sSLo rvpn.tar.gz "https://github.com/redpwn/rvpn/releases/download/$version/rvpn_darwin_$arch.tar.gz"

# extract tar
tar -xzvf rvpn.tar.gz

# install rvpn and rvpn service
$sudo install -Dm 644 -t /Library/LaunchDaemons rvpn_darwin_$arch/launchd/rvpn.service
$sudo install -m 755 -t /usr/local/bin/ rvpn_linux_$arch/bin/rvpn

$sudo launchctl load /Library/LaunchDaemons/dev.rvpn.plist

echo "Start rvpn daemon?"
select yn in "Start" "Skip"; do
case $yn in
"Start" ) $sudo launchctl start /Library/LaunchDaemons/dev.rvpn.plist break;;
"Skip" ) break;;
esac
done

# print success and remind user to allow rvpn serve port (21820) through firewall if serving
echo "Successfully installed rVPN!"
}

main
15 changes: 12 additions & 3 deletions support/install.sh → support/install-linux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ main() {

# ask user if they want to enable ip forwarding if not already enabled
if [ "$(cat /proc/sys/net/ipv4/ip_forward)" -eq 0 ]; then
echo "Do you wish to enable IP Forwarding (only used if this device is a VPN server)? [1,2]"
echo "Do you wish to enable IP Forwarding (only used if this device is a VPN server)?"
select yn in "Yes" "No"; do
case $yn in
Yes ) enable_ip4_forwarding $sudo ; break;;
Expand All @@ -55,12 +55,21 @@ main() {
fi

# install rvpn and rvpn service
$sudo install -Dm 644 -t /usr/local/lib/systemd/system/ rvpn_linux_$arch/systemd/systemd/rvpn.service
$sudo install -Dm 644 -t /usr/local/lib/systemd/system/ rvpn_linux_$arch/systemd/rvpn.service
$sudo install -m 755 -t /usr/local/bin/ rvpn_linux_$arch/bin/rvpn

echo "Start rvpn daemon?"
select yn in "Enable (start on boot)" "Start" "Skip"; do
case $yn in
"Enable (start on boot)" ) $sudo systemctl enable --now rvpn ; break;;
"Start" ) $sudo systemctl start rvpn break;;
"Skip" ) break;;
esac
done

# print success and remind user to allow rvpn serve port (21820) through firewall if serving
echo "Successfully installed rVPN!"
echo "If using this device as a VPN server please allow rVPN serve port (default 21820) through firewall"
echo "NOTE: If using this device as a VPN server please allow rVPN serve port (default 21820) through firewall"
}

main
26 changes: 26 additions & 0 deletions support/launchd/dev.rvpn.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>EnvironmentVariables</key>
<dict>
<key>PATH</key>
<string>/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:</string>
</dict>
<key>Label</key>
<string>dev.rvpn</string>
<key>ProgramArguments</key>
<array>
<string>/usr/local/bin/rvpn</string>
<string>daemon</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>KeepAlive</key>
<true/>
<key>StandardOutPath</key>
<string>/tmp/startup.stdout</string>
<key>StandardErrorPath</key>
<string>/tmp/startup.stderr</string>
</dict>
</plist>