Skip to content

Commit ffbb712

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

File tree

3 files changed

+79
-24
lines changed

3 files changed

+79
-24
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

+42-24
Original file line numberDiff line numberDiff line change
@@ -11,61 +11,79 @@
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 || exit 9
53+
54+
echo ". Enabling Redis at boot"
55+
systemctl enable redis || exit 10
56+
57+
echo ". Enabling SMA-X at boot"
58+
systemctl enable smax-scripts || exit 11
4959
else
5060
# prompt for choices
61+
echo "Manual installation..."
5162

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

5870
read -p "start redis with SMA-X scripts at this time? " -n 1 -r
5971
echo # (optional) move to a new line
6072
if [[ $REPLY =~ ^[Yy]$ ]] ; then
61-
systemctl restart smax-scripts || exit 11
73+
echo ". Starting smax-scripts service"
74+
systemctl restart smax-scripts || exit 13
6275
fi
6376

6477
read -p "Enable and start SMA-X at boot time? " -n 1 -r
6578
echo # (optional) move to a new line
6679
if [[ $REPLY =~ ^[Yy]$ ]] ; then
67-
systemctl enable redis || exit 12
68-
systemctl enable smax-scripts || exit 13
80+
echo ". Enabling Redis at boot"
81+
systemctl enable redis || exit 14
82+
83+
echo ". Enabling SMA-X at boot"
84+
systemctl enable smax-scripts || exit 15
6985
fi
7086
fi
7187

88+
89+
echo "Done!"

0 commit comments

Comments
 (0)