Wireguard installation and basics for client usage on raspbians
This commit is contained in:
93
seqs/wireguard.sh
Executable file
93
seqs/wireguard.sh
Executable file
@@ -0,0 +1,93 @@
|
||||
#!/bin/bash
|
||||
|
||||
toolName=wireguard
|
||||
toolBin=wg
|
||||
toolDefaultConf=wg0
|
||||
toolService=wg-quick@$toolDefaultConf
|
||||
|
||||
# Get script working directory
|
||||
# (when called from a different directory)
|
||||
WDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >>/dev/null 2>&1 && pwd )"
|
||||
CONFIG=0
|
||||
CONFIG_FILE_NAME="${toolName}.cfg"
|
||||
CONFIG_FILE_TEMPLATE="$WDIR/${CONFIG_FILE_NAME}.example"
|
||||
|
||||
#step_config() {
|
||||
#echo "Called once before executing steps."
|
||||
## e.g. to source a config file manually:
|
||||
#. "$CONFIG_FILE"
|
||||
## or to use sequencer api:
|
||||
#initSeqConfig "$CONFIG_FILE_NAME" "$CONFIG_FILE_TEMPLATE"
|
||||
#if [ $? -eq 0 ] ; then
|
||||
# CONFIG=1
|
||||
#fi
|
||||
#}
|
||||
|
||||
step_1_info() { echo "Prepare installation of $toolName"; }
|
||||
step_1_alias() { ALIAS="install"; }
|
||||
step_1() {
|
||||
exe apt install raspberrypi-kernel-headers
|
||||
endReturn -o $? "Installation of kernel headers failed"
|
||||
addConf -s "deb http://deb.debian.org/debian/ unstable main" "/etc/apt/sources.list.d/unstable.list"
|
||||
exep "wget -O - https://ftp-master.debian.org/keys/archive-key-$(lsb_release -sr).asc | sudo apt-key add -"
|
||||
addConf -s "$pinEntry" "/etc/apt/preferences.d/limit-unstable"
|
||||
exe apt update
|
||||
}
|
||||
pinEntry="Package: *
|
||||
Pin: release a=unstable
|
||||
Pin-Priority: 150"
|
||||
|
||||
step_2_info() { echo "Installing $toolName"; }
|
||||
step_2() {
|
||||
local aptOpt=""
|
||||
if [ $QUIET -ne 0 ] ; then
|
||||
aptOpt="-y"
|
||||
fi
|
||||
exe apt install $toolName $aptOpt
|
||||
}
|
||||
|
||||
step_3_info() {
|
||||
echo "Enable ipv4 forwarding to allow local access via VPN"
|
||||
echoinfo "(may be skipped)"
|
||||
}
|
||||
step_3_alias() { ALIAS="ipv4"; }
|
||||
step_3() {
|
||||
exe perl -pi -e 's/#{1,}?net.ipv4.ip_forward ?= ?(0|1)/net.ipv4.ip_forward = 1/g' /etc/sysctl.conf
|
||||
}
|
||||
|
||||
step_4_info() { echo "Reboot to make changes active"; }
|
||||
step_4() {
|
||||
exe reboot
|
||||
}
|
||||
|
||||
step_10_info() { echo "Start default configuration $toolDefaultConf"; }
|
||||
step_10_alias() { ALIAS="start"; }
|
||||
step_10() {
|
||||
exe wg-quick up wg0
|
||||
}
|
||||
|
||||
step_12_info() { echo "Stop default configuration $toolDefaultConf"; }
|
||||
step_12_alias() { ALIAS="stop"; }
|
||||
step_12() {
|
||||
exe wg-quick down wg0
|
||||
}
|
||||
|
||||
step_14_info() { echo "Enable default configuration $defaultConfLoc"; }
|
||||
step_14_alias() { ALIAS="enable"; }
|
||||
step_14() {
|
||||
if [ ! -r "$defaultConfLoc" ] ; then
|
||||
endReturn -o 1 "Default configuration \"$defaultConfLoc\" not found"
|
||||
fi
|
||||
exe systemctl enable wg-quick@wg0
|
||||
}
|
||||
defaultConfLoc="/etc/$toolName/$toolDefaultConf.conf"
|
||||
|
||||
|
||||
step_20_info() { echo "Usage notes"; }
|
||||
step_20() {
|
||||
echo " [I] Some usage Notes"
|
||||
}
|
||||
|
||||
|
||||
VERSION_SEQREV=11
|
||||
. /usr/local/bin/sequencer.sh
|
Reference in New Issue
Block a user