Skip to content

Commit c2f4a48

Browse files
committed
Add Github Actions CI
1 parent 06cbc05 commit c2f4a48

File tree

4 files changed

+87
-22
lines changed

4 files changed

+87
-22
lines changed

.github/dependabot.yml

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# To get started with Dependabot version updates, you'll need to specify which
2+
# package ecosystems to update and where the package manifests are located.
3+
# Please see the documentation for all configuration options:
4+
# https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file
5+
6+
version: 2
7+
updates:
8+
- package-ecosystem: "github-actions"
9+
directory: "/"
10+
schedule:
11+
interval: "weekly"

.github/workflows/test.yml

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: Test installer
2+
3+
on:
4+
push:
5+
paths:
6+
- '*.sh'
7+
- 'lua/**'
8+
- 'smax-scripts.service'
9+
- '.github/workflows/test.yml'
10+
11+
jobs:
12+
13+
test:
14+
name: Test on Ubuntu
15+
16+
runs-on: ubuntu-latest
17+
steps:
18+
- name: install redis
19+
run: sudo apt install redis
20+
21+
- name: Check out smax-server
22+
uses: actions/checkout@v4
23+
24+
- name: Run installer
25+
run: sudo ./install.sh auto
26+

install.sh

+49-20
Original file line numberDiff line numberDiff line change
@@ -11,61 +11,90 @@
1111
# 09/14/2024
1212
#
1313

14-
if [ $EUID -ne 0 ]
15-
then echo "Please run as root"
14+
if [ $EUID -ne 0 ] ; then
15+
echo "Please run as root"
1616
exit 1
1717
fi
1818

19-
# You can configure DESTDIR before calling this script to install to a location other
20-
# than /usr (e.g. /usr/local or /opt).
2119
if [ "$DESTDIR" == "" ] ; then
2220
DESTDIR="/usr"
2321
fi
2422

2523
# Create /usr/share/smax and its lua/ sub-directory
26-
SMAX="$(DESTDIR)/share/smax"
24+
SMAX="$DESTDIR/share/smax"
2725

2826
# 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
3132

3233
# 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
3545

3646
# Register smax-scripts with systemd
37-
systemctl daemon-reload || exit 5
47+
echo ". Reloading systemd daemon"
48+
systemctl daemon-reload || exit 7
3849

3950
# if you call the script with a single argument 'auto', then it will install
4051
# a default without asking any questions. (Without the option, the installer
4152
# will ask you to make some choices.)
4253
if [ "$1" == "auto" ] ; then
43-
# automatic installation
54+
# automatic installation
55+
echo "Automatic installation..."
4456

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
4970
else
5071
# prompt for choices
72+
echo "Manual installation..."
5173

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
5375
echo # (optional) move to a new line
5476
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
5679
fi
5780

5881
read -p "start redis with SMA-X scripts at this time? " -n 1 -r
5982
echo # (optional) move to a new line
6083
if [[ $REPLY =~ ^[Yy]$ ]] ; then
61-
systemctl restart smax-scripts || exit 11
84+
echo ". Starting smax-scripts service"
85+
systemctl restart smax-scripts || exit 13
6286
fi
6387

6488
read -p "Enable and start SMA-X at boot time? " -n 1 -r
6589
echo # (optional) move to a new line
6690
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
6996
fi
7097
fi
7198

99+
100+
echo "Done!"

smax-scripts.service

+1-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@ After=redis.service
55

66
[Service]
77
Type=oneshot
8-
WorkingDirectory=/usr/share/smax
9-
ExecStart=/usr/sbin/smax-init.sh
8+
ExecStart=/usr/bin/smax-init.sh
109
RemainAfterExit=yes
1110

1211
[Install]

0 commit comments

Comments
 (0)