Skip to content

Commit 713f410

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

File tree

4 files changed

+87
-26
lines changed

4 files changed

+87
-26
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-24
Original file line numberDiff line numberDiff line change
@@ -11,61 +11,86 @@
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).
21-
if [ "$DESTDIR" == "" ] ; then
22-
DESTDIR="/usr"
23-
fi
24-
2519
# Create /usr/share/smax and its lua/ sub-directory
26-
SMAX="$(DESTDIR)/share/smax"
20+
SMAX="$DESTDIR/share/smax"
2721

2822
# 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/lua/ || exit 3
3128

3229
# 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 ". Setting DESTDIR in script loader"
34+
sed -i "s:/usr:$DESTDIR:g" $DESTDIR/bin/smax-scripts.service || exit 6
35+
36+
echo ". Copying script loader to /etc/systemd/system"
37+
install -m 644 smax-scripts.service /etc/systemd/system/ || exit 5
38+
39+
echo ". Setting DESTDIR in systemd unit"
40+
sed -i "s:/usr:$DESTDIR:g" /etc/systemd/system/smax-scripts.service || exit 6
3541

3642
# Register smax-scripts with systemd
37-
systemctl daemon-reload || exit 5
43+
echo ". Reloading systemd daemon"
44+
systemctl daemon-reload || exit 7
3845

3946
# if you call the script with a single argument 'auto', then it will install
4047
# a default without asking any questions. (Without the option, the installer
4148
# will ask you to make some choices.)
4249
if [ "$1" == "auto" ] ; then
43-
# automatic installation
50+
# automatic installation
51+
echo "Automatic installation..."
4452

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
53+
echo ". Removing SMA-specific sections from scripts"
54+
sed -i '/^.*BEGIN SMA.*/,/^.*END SMA.*/d' $SMAX/lua/*.lua || exit 8
55+
56+
echo ". Starting smax-scripts service"
57+
systemctl restart smax-scripts
58+
59+
journalctl -xeu smax-scripts.service
60+
61+
echo ". Enabling Redis at boot"
62+
systemctl enable redis || exit 10
63+
64+
echo ". Enabling SMA-X at boot"
65+
systemctl enable smax-scripts || exit 11
4966
else
5067
# prompt for choices
68+
echo "Manual installation..."
5169

52-
read -p "Are you going to use SMA-X at the SMA? " -n 1 -r
70+
read -p "Are you going to use SMA-X outside of the SMA? " -n 1 -r
5371
echo # (optional) move to a new line
5472
if [[ $REPLY =~ ^[Yy]$ ]] ; then
55-
sed -i '/^.*BEGIN SMA.*/,/^.*END SMA.*$/d' *.lua || exit 10
73+
echo ". Removing SMA-specific sections from scripts"
74+
sed -i '/^.*BEGIN SMA.*/,/^.*END SMA.*$/d' *.lua || exit 12
5675
fi
5776

5877
read -p "start redis with SMA-X scripts at this time? " -n 1 -r
5978
echo # (optional) move to a new line
6079
if [[ $REPLY =~ ^[Yy]$ ]] ; then
61-
systemctl restart smax-scripts || exit 11
80+
echo ". Starting smax-scripts service"
81+
systemctl restart smax-scripts || exit 13
6282
fi
6383

6484
read -p "Enable and start SMA-X at boot time? " -n 1 -r
6585
echo # (optional) move to a new line
6686
if [[ $REPLY =~ ^[Yy]$ ]] ; then
67-
systemctl enable redis || exit 12
68-
systemctl enable smax-scripts || exit 13
87+
echo ". Enabling Redis at boot"
88+
systemctl enable redis || exit 14
89+
90+
echo ". Enabling SMA-X at boot"
91+
systemctl enable smax-scripts || exit 15
6992
fi
7093
fi
7194

95+
96+
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)