-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathinstall.sh
executable file
·81 lines (72 loc) · 1.42 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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#!/bin/bash
if [ "$EUID" -ne 0 ]
then
echo "Please run as root to install the usbip service."
exit 1
fi
case "$1" in
client)
service='attach'
module='vhci_hcd'
if [ -z "$2" ]
then
host='pi'
else
host="$2"
fi
;;
server)
service='bind'
module='usbip-host'
;;
*)
printf 'Usage: %s (client [hostname] | server)\n' "$(basename "$0")"
exit 0
;;
esac
echo -n "Creating installation directory ."
mkdir -p /opt/usbip
echo ". done."
echo -n "Installing application files ."
cp usbip-${service} /opt/usbip/usbip-${service}
cp usbip-${service}.service /etc/systemd/system/usbip-${service}.service
chmod +x /opt/usbip/usbip-${service}
echo ". done."
if [[ "${service}" == "attach" ]]
then
echo -n "Setting server hostname to '${host}' ."
sed -i "s|usbip_server_host_name|${host}|g" /opt/usbip/usbip-${service}
echo ". done."
fi
echo -n "Loading kernel module '${module}' ."
if modprobe "${module}" >/dev/null 2>&1
then
echo ". done."
else
echo ". failed."
exit 1
fi
echo -n "Reloading systemctl daemon ."
if systemctl daemon-reload >/dev/null 2>&1
then
echo ". done."
else
echo ". failed."
exit 1
fi
echo -n "Enabling usbip-${service} service ."
if systemctl enable usbip-${service} >/dev/null 2>&1
then
echo ". done."
else
echo ". failed."
exit 1
fi
echo -n "Starting usbip-${service} service ."
if systemctl start usbip-${service} >/dev/null 2>&1
then
echo ". done."
else
echo ". failed."
exit 1
fi