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