Skip to content

Commit

Permalink
Add Github Actions CI
Browse files Browse the repository at this point in the history
  • Loading branch information
attipaci committed Sep 14, 2024
1 parent 06cbc05 commit 91b2f65
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 18 deletions.
11 changes: 11 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file

version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
26 changes: 26 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Test installer

on:
push:
paths:
- '*.sh'
- 'lua/**'
- 'smax-scripts.service'
- '.github/workflows/test.yml'

jobs:

test:
name: Test on Ubuntu

runs-on: ubuntu-latest
steps:
- name: install redis
run: sudo apt-get install redis

- name: Check out smax-server
uses: actions/checkout@v4

- name: Run installer
run: sudo ./install.sh auto

59 changes: 41 additions & 18 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
# 09/14/2024
#

if [ $EUID -ne 0 ]
then echo "Please run as root"
if [ $EUID -ne 0 ] ; then
echo "Please run as root"
exit 1
fi

Expand All @@ -23,49 +23,72 @@ if [ "$DESTDIR" == "" ] ; then
fi

# Create /usr/share/smax and its lua/ sub-directory
SMAX="$(DESTDIR)/share/smax"
SMAX="$DESTDIR/share/smax"

# Copy LUA script over to /usr/share/smax
mkdir -p $SMAX/lua || exit 1
cp -a lua $SMAX || exit 2
echo ". Creating $SMAX/lua directory"
mkdir -p $SMAX/lua || exit 2

echo ". Copying LUA scripts to $SMAX/lua"
cp -a lua $SMAX || exit 3

# install script loader and systemd unit file
install -m 755 smax-init.sh /usr/bin/ || ( exho exit 3
install -m 644 smax-scripts.service /etc/systemd/system/ || exit 4
echo ". Copying script loader to $DESTDIR/bin"
install -m 755 smax-init.sh $DESTDIR/bin/ || echo exit 4

echo ". Copying script loader to /etc/systemd/system"
install -m 644 smax-scripts.service /etc/systemd/system/ || exit 5

# Register smax-scripts with systemd
systemctl daemon-reload || exit 5
echo ". Reloading systemd daemon"
systemctl daemon-reload || exit 6

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

sed -i '/^.*BEGIN SMA.*/,/^.*END SMA.*$/d' *.lua || exit 6
systemctl restart smax-scripts || exit 7
systemctl enable redis || exit 8
systemctl enable smax-scripts || exit 9
echo ". Removing SMA-specific sections from scripts"
sed -i '/^.*BEGIN SMA.*/,/^.*END SMA.*$/d' *.lua || exit 7

echo ". Starting smax-scripts service"
systemctl restart smax-scripts || exit 8

echo ". Enabling Redis at boot"
systemctl enable redis || exit 9

echo ". Enabling SMA-X at boot"
systemctl enable smax-scripts || exit 10
else
# prompt for choices
echo "Manual installation..."

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

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

read -p "Enable and start SMA-X at boot time? " -n 1 -r
echo # (optional) move to a new line
if [[ $REPLY =~ ^[Yy]$ ]] ; then
systemctl enable redis || exit 12
systemctl enable smax-scripts || exit 13
echo ". Enabling Redis at boot"
systemctl enable redis || exit 13

echo ". Enabling SMA-X at boot"
systemctl enable smax-scripts || exit 14
fi
fi


echo "Done!"

0 comments on commit 91b2f65

Please sign in to comment.