-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
executable file
·36 lines (28 loc) · 1.33 KB
/
install.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/bin/sh
set -e
if [ "$(id -u)" -ne 0 ]; then
echo "This script must be run as root" 1>&2
exec sudo sh "$0" "$@"
fi
PIPX_HOME=/opt/pipx PIPX_BIN_DIR=/usr/local/bin pipx install wirescale || true
UNIT='wirescaled'
SERVICE="$UNIT.service"
SOCKET="$UNIT.socket"
systemctl stop "$SERVICE" > /dev/null 2>&1 || true
systemctl stop "$SOCKET" > /dev/null 2>&1 || true
systemctl disable "$SERVICE" > /dev/null 2>&1 || true
systemctl disable "$SOCKET" > /dev/null 2>&1 || true
rm -rf "/etc/systemd/system/$SERVICE" > /dev/null 2>&1 || true
rm -rf "/etc/systemd/system/$SOCKET" > /dev/null 2>&1 || true
rm -rf "/etc/bash_completion.d/wirescale-completion" > /dev/null 2>&1 || true
rm -rf "/etc/iproute2/rt_tables.d/wirescale.conf" > /dev/null 2>&1 || true
systemctl daemon-reload
PYTHON_DIR=$(find /opt/pipx/venvs/wirescale/lib -name 'python*' -type d)
ln -s "$PYTHON_DIR/site-packages/wirescale/systemd/$SOCKET" "/etc/systemd/system/"
ln -s "$PYTHON_DIR/site-packages/wirescale/systemd/$SERVICE" "/etc/systemd/system/"
ln -s "$PYTHON_DIR/site-packages/wirescale/scripts/wirescale-completion" "/etc/bash_completion.d/"
echo -e "# wirescale table\n#\n2693596026 wirescale" > "/etc/iproute2/rt_tables.d/wirescale.conf"
systemctl daemon-reload
systemctl enable "$SOCKET" "$SERVICE"
systemctl start "$SERVICE"
echo "Success! Wirescale has been installed"