Last active
July 14, 2020 08:42
-
-
Save splatch/963890ac8268f6c443d8db0c651766a5 to your computer and use it in GitHub Desktop.
Working wireguard client recipe
This file contains 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
DESCRIPTION = "Wireguard VPN client configuration on /data partition" | |
HOMEPAGE = "https://connectorio.com/" | |
LICENSE = "MIT" | |
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302" | |
# variables used to pre-populate wireguard interface | |
export WG_CLIENT_ADDRESS ?= "" | |
export WG_CLIENT_PRIVATE_KEY ?= "" | |
export WG_CLIENT_PRESHARED_KEY ?= "" | |
export WG_CLIENT_ALLOWED_IP ?= "" | |
export WG_CLIENT_KEEP_ALIVE ?= "15" | |
export WG_SERVER_PUBLIC_KEY ?= "" | |
export WG_SERVER_ADDRESS ?= "" | |
export WG_SERVER_PORT ?= "51820" | |
DEPENDS_${PN} = "wireguard-tools systemd" | |
RDEPENDS_${PN} = "wireguard-tools systemd" | |
PACKAGECONFIG = "wireguard-tools systemd" | |
# Additional file necessary to fix systemd unit location, patched | |
# file://wg-quick@.service | |
SRC_URI = " \ | |
file://wg0.conf \ | |
" | |
PR = "r1" | |
do_configure[noexec] = "1" | |
do_compile[noexec] = "1" | |
do_install() { | |
install -d -m 0700 ${D}${PERSISTENT_DATA_DIR}/system/etc/wireguard | |
install -m 0640 ${WORKDIR}/wg0.conf ${D}${PERSISTENT_DATA_DIR}/system/etc/wireguard/wg0.conf | |
install -d -m 0700 ${D}${sysconfdir}/wireguard | |
lnr ${D}${PERSISTENT_DATA_DIR}/system/etc/wireguard/wg0.conf ${D}${sysconfdir}/wireguard/wg0.conf | |
sed -i -e "s#@WG_CLIENT_ADDRESS@#$WG_CLIENT_ADDRESS#g" \ | |
-e "s#@WG_CLIENT_PRIVATE_KEY@#$WG_CLIENT_PRIVATE_KEY#g" \ | |
-e "s#@WG_CLIENT_PRESHARED_KEY@#$WG_CLIENT_PRESHARED_KEY#g" \ | |
-e "s#@WG_CLIENT_ALLOWED_IP@#$WG_CLIENT_ALLOWED_IP#g" \ | |
-e "s#@WG_CLIENT_KEEP_ALIVE@#$WG_CLIENT_KEEP_ALIVE#g" \ | |
-e "s#@WG_SERVER_PUBLIC_KEY@#$WG_SERVER_PUBLIC_KEY#g" \ | |
-e "s#@WG_SERVER_PORT@#$WG_SERVER_PORT#g" \ | |
-e "s#@WG_SERVER_ADDRESS@#$WG_SERVER_ADDRESS#g" \ | |
${D}${PERSISTENT_DATA_DIR}/system/etc/wireguard/wg0.conf | |
} | |
# ${systemd_system_unitdir}/wg-quick@.service | |
FILES_${PN} = "\ | |
${PERSISTENT_DATA_DIR}/system/etc/wireguard/wg0.conf \ | |
${sysconfdir}/wireguard/wg0.conf \ | |
" | |
# Below section will not work unless we switch recipe to append to wireguard-tools | |
# we leave it commented cause it is enabled during first boot | |
#inherit systemd | |
#SYSTEMD_PACKAGES = "wireguard-tools" | |
#SYSTEMD_PACKAGES_${PN} = "wireguard-tools" | |
#SYSTEMD_SERVICE_${PN} = "wg-quick@wg0.service" | |
#SYSTEMD_AUTO_ENABLE = "enable" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment