Skip to content

Commit 3f13d35

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

File tree

4 files changed

+81
-25
lines changed

4 files changed

+81
-25
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-get 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

+44-24
Original file line numberDiff line numberDiff line change
@@ -11,61 +11,81 @@
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 || 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 ". Copying script loader to /etc/systemd/system"
34+
install -m 644 smax-scripts.service /etc/systemd/system/ || exit 5
35+
sed -i "s:/usr:$DESTDIR:g" /etc/systemd/system/smax-scripts.service || exit 6
3536

3637
# Register smax-scripts with systemd
37-
systemctl daemon-reload || exit 5
38+
echo ". Reloading systemd daemon"
39+
systemctl daemon-reload || exit 7
3840

3941
# if you call the script with a single argument 'auto', then it will install
4042
# a default without asking any questions. (Without the option, the installer
4143
# will ask you to make some choices.)
4244
if [ "$1" == "auto" ] ; then
43-
# automatic installation
45+
# automatic installation
46+
echo "Automatic installation..."
4447

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
48+
echo ". Removing SMA-specific sections from scripts"
49+
sed -i '/^.*BEGIN SMA.*/,/^.*END SMA.*$/d' $SMAX/lua/*.lua || exit 8
50+
51+
echo ". Starting smax-scripts service"
52+
systemctl restart smax-scripts
53+
54+
systemctl status smax-scripts
55+
56+
echo ". Enabling Redis at boot"
57+
systemctl enable redis || exit 10
58+
59+
echo ". Enabling SMA-X at boot"
60+
systemctl enable smax-scripts || exit 11
4961
else
5062
# prompt for choices
63+
echo "Manual installation..."
5164

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

5872
read -p "start redis with SMA-X scripts at this time? " -n 1 -r
5973
echo # (optional) move to a new line
6074
if [[ $REPLY =~ ^[Yy]$ ]] ; then
61-
systemctl restart smax-scripts || exit 11
75+
echo ". Starting smax-scripts service"
76+
systemctl restart smax-scripts || exit 13
6277
fi
6378

6479
read -p "Enable and start SMA-X at boot time? " -n 1 -r
6580
echo # (optional) move to a new line
6681
if [[ $REPLY =~ ^[Yy]$ ]] ; then
67-
systemctl enable redis || exit 12
68-
systemctl enable smax-scripts || exit 13
82+
echo ". Enabling Redis at boot"
83+
systemctl enable redis || exit 14
84+
85+
echo ". Enabling SMA-X at boot"
86+
systemctl enable smax-scripts || exit 15
6987
fi
7088
fi
7189

90+
91+
echo "Done!"

smax-scripts.service

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

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

0 commit comments

Comments
 (0)