|
11 | 11 | # 09/14/2024
|
12 | 12 | #
|
13 | 13 |
|
14 |
| -if [ $EUID -ne 0 ] |
15 |
| - then echo "Please run as root" |
| 14 | +if [ $EUID -ne 0 ] ; then |
| 15 | + echo "Please run as root" |
16 | 16 | exit 1
|
17 | 17 | fi
|
18 | 18 |
|
19 |
| -# You can configure DESTDIR before calling this script to install to a location other |
20 |
| -# than /usr (e.g. /usr/local or /opt). |
21 |
| -if [ "$DESTDIR" == "" ] ; then |
22 |
| - DESTDIR="/usr" |
23 |
| -fi |
24 |
| - |
25 | 19 | # Create /usr/share/smax and its lua/ sub-directory
|
26 |
| -SMAX="$(DESTDIR)/share/smax" |
| 20 | +SMAX="$DESTDIR/share/smax" |
27 | 21 |
|
28 | 22 | # Copy LUA script over to /usr/share/smax
|
29 |
| -mkdir -p $SMAX/lua || exit 1 |
30 |
| -cp -a lua $SMAX || exit 2 |
| 23 | +echo ". Creating $SMAX/lua directory" |
| 24 | +mkdir -p $SMAX/lua || exit 2 |
| 25 | + |
| 26 | +echo ". Copying LUA scripts to $SMAX/lua" |
| 27 | +cp -a lua $SMAX || exit 3 |
31 | 28 |
|
32 | 29 | # install script loader and systemd unit file
|
33 |
| -install -m 755 smax-init.sh /usr/bin/ || ( exho exit 3 |
34 |
| -install -m 644 smax-scripts.service /etc/systemd/system/ || exit 4 |
| 30 | +echo ". Copying script loader to $DESTDIR/bin" |
| 31 | +install -m 755 smax-init.sh $DESTDIR/bin/ || echo exit 4 |
| 32 | + |
| 33 | +echo ". Copying script loader to /etc/systemd/system" |
| 34 | +install -m 644 smax-scripts.service /etc/systemd/system/ || exit 5 |
| 35 | + |
| 36 | +echo ". Setting DESTDIR in systemd unit" |
| 37 | +sed -i "s:/usr:$DESTDIR:g" /etc/systemd/system/smax-scripts.service || exit 6 |
35 | 38 |
|
36 | 39 | # Register smax-scripts with systemd
|
37 |
| -systemctl daemon-reload || exit 5 |
| 40 | +echo ". Reloading systemd daemon" |
| 41 | +systemctl daemon-reload || exit 7 |
38 | 42 |
|
39 | 43 | # if you call the script with a single argument 'auto', then it will install
|
40 | 44 | # a default without asking any questions. (Without the option, the installer
|
41 | 45 | # will ask you to make some choices.)
|
42 | 46 | if [ "$1" == "auto" ] ; then
|
43 |
| - # automatic installation |
| 47 | + # automatic installation |
| 48 | + echo "Automatic installation..." |
44 | 49 |
|
45 |
| - sed -i '/^.*BEGIN SMA.*/,/^.*END SMA.*$/d' *.lua || exit 6 |
46 |
| - systemctl restart smax-scripts || exit 7 |
47 |
| - systemctl enable redis || exit 8 |
48 |
| - systemctl enable smax-scripts || exit 9 |
| 50 | + echo ". Removing SMA-specific sections from scripts" |
| 51 | + sed -i '/^.*BEGIN SMA.*/,/^.*END SMA.*$/d' $SMAX/lua/*.lua || exit 8 |
| 52 | + |
| 53 | + echo ". Starting smax-scripts service" |
| 54 | + systemctl restart smax-scripts |
| 55 | + |
| 56 | + systemctl status smax-scripts |
| 57 | + |
| 58 | + echo ". Enabling Redis at boot" |
| 59 | + systemctl enable redis || exit 10 |
| 60 | + |
| 61 | + echo ". Enabling SMA-X at boot" |
| 62 | + systemctl enable smax-scripts || exit 11 |
49 | 63 | else
|
50 | 64 | # prompt for choices
|
| 65 | + echo "Manual installation..." |
51 | 66 |
|
52 |
| - read -p "Are you going to use SMA-X at the SMA? " -n 1 -r |
| 67 | + read -p "Are you going to use SMA-X outside of the SMA? " -n 1 -r |
53 | 68 | echo # (optional) move to a new line
|
54 | 69 | if [[ $REPLY =~ ^[Yy]$ ]] ; then
|
55 |
| - sed -i '/^.*BEGIN SMA.*/,/^.*END SMA.*$/d' *.lua || exit 10 |
| 70 | + echo ". Removing SMA-specific sections from scripts" |
| 71 | + sed -i '/^.*BEGIN SMA.*/,/^.*END SMA.*$/d' *.lua || exit 12 |
56 | 72 | fi
|
57 | 73 |
|
58 | 74 | read -p "start redis with SMA-X scripts at this time? " -n 1 -r
|
59 | 75 | echo # (optional) move to a new line
|
60 | 76 | if [[ $REPLY =~ ^[Yy]$ ]] ; then
|
61 |
| - systemctl restart smax-scripts || exit 11 |
| 77 | + echo ". Starting smax-scripts service" |
| 78 | + systemctl restart smax-scripts || exit 13 |
62 | 79 | fi
|
63 | 80 |
|
64 | 81 | read -p "Enable and start SMA-X at boot time? " -n 1 -r
|
65 | 82 | echo # (optional) move to a new line
|
66 | 83 | if [[ $REPLY =~ ^[Yy]$ ]] ; then
|
67 |
| - systemctl enable redis || exit 12 |
68 |
| - systemctl enable smax-scripts || exit 13 |
| 84 | + echo ". Enabling Redis at boot" |
| 85 | + systemctl enable redis || exit 14 |
| 86 | + |
| 87 | + echo ". Enabling SMA-X at boot" |
| 88 | + systemctl enable smax-scripts || exit 15 |
69 | 89 | fi
|
70 | 90 | fi
|
71 | 91 |
|
| 92 | + |
| 93 | +echo "Done!" |
0 commit comments