-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmsd_lite.sh
34 lines (27 loc) · 1.2 KB
/
msd_lite.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
#!/bin/bash
# Read network interface name and port from environment variables or command line arguments
ifName=${IFNAME:-$1}
port=${PORT:-$2}
# Check if the msd_lite configuration file exists
if [ -f /etc/msd_lite/msd_lite.conf ]; then
# If the configuration file exists, run msd_lite with it
/usr/local/bin/msd_lite -c /etc/msd_lite/msd_lite.conf
else
# If not, copy the sample configuration file to the directory
cp /usr/local/etc/msd_lite/msd_lite.conf.sample /etc/msd_lite/msd_lite.conf.sample
fi
# Exit if no network interface name is provided
if [ -z "$ifName" ]; then
echo "Please modify /etc/msd_lite/msd_lite.conf.sample and rename it to msd_lite.conf. Exiting."
exit 1
fi
# Copy the configuration file from root to the correct location
cp /root/msd_lite.conf /etc/msd_lite/msd_lite.conf
# Replace the placeholder with the actual network interface name
sed -i "s/@ifName@/$ifName/g" /etc/msd_lite/msd_lite.conf
# If a port is provided, replace the default port with it
if [ ! -z "$port" ]; then
sed -i "s/7088/$port/g" /etc/msd_lite/msd_lite.conf
fi
# Execute msd_lite with the configuration file
/usr/local/bin/msd_lite -c /etc/msd_lite/msd_lite.conf