Added basic semaphore scripts

This commit is contained in:
Eliezer Croitoru 2024-09-01 03:13:03 +03:00
parent ab0074c0a4
commit a047599fc8
2 changed files with 80 additions and 0 deletions

23
create-semaphore-db.sql Normal file
View File

@ -0,0 +1,23 @@
CREATE DATABASE semaphore;
CREATE USER 'semaphore'@'localhost' IDENTIFIED BY 'semaphore';
GRANT Usage ON *.* TO 'semaphore'@'localhost';
GRANT Alter ON semaphore.* TO 'semaphore'@'localhost';
GRANT Create ON semaphore.* TO 'semaphore'@'localhost';
GRANT Create view ON semaphore.* TO 'semaphore'@'localhost';
GRANT Delete ON semaphore.* TO 'semaphore'@'localhost';
GRANT Delete history ON semaphore.* TO 'semaphore'@'localhost';
GRANT Drop ON semaphore.* TO 'semaphore'@'localhost';
GRANT Index ON semaphore.* TO 'semaphore'@'localhost';
GRANT Insert ON semaphore.* TO 'semaphore'@'localhost';
GRANT References ON semaphore.* TO 'semaphore'@'localhost';
GRANT Select ON semaphore.* TO 'semaphore'@'localhost';
GRANT Show view ON semaphore.* TO 'semaphore'@'localhost';
GRANT Trigger ON semaphore.* TO 'semaphore'@'localhost';
GRANT Update ON semaphore.* TO 'semaphore'@'localhost';
GRANT Alter routine ON semaphore.* TO 'semaphore'@'localhost';
GRANT Create routine ON semaphore.* TO 'semaphore'@'localhost';
GRANT Create temporary tables ON semaphore.* TO 'semaphore'@'localhost';
GRANT Execute ON semaphore.* TO 'semaphore'@'localhost';
GRANT Lock tables ON semaphore.* TO 'semaphore'@'localhost';
GRANT Show Create Routine ON semaphore.* TO 'semaphore'@'localhost';

57
install-semaphore.sh Normal file
View File

@ -0,0 +1,57 @@
#!/usr/bin/env bash
dnf install -y jq
RPM_URL="https://github.com/semaphoreui/semaphore/releases/download/v2.10.22/semaphore_2.10.22_linux_amd64.rpm"
OUTPUT_FILENAME="semaphore_2.10.22_linux_amd64.rpm"
wget "${RPM_URL}" -O "${OUTPUT_FILENAME}"
dnf localinstall -y ./semaphore*amd64.rpm
dnf module disable mariadb -y
wget "https://downloads.mariadb.com/MariaDB/mariadb_repo_setup" -O "mariadb_repo_setup"
# Checksum check
bash "mariadb_repo_setup"
dnf install mariadb-server -y
systemctl start mariadb
systemctl enable mariadb
## Create database and user
## setup semaphore
## install config
mkdir -p /etc/semaphore
cp -vf config.json /etc/semaphore/
##Create service
cat > /etc/systemd/system/semaphore.service <<EOF
[Unit]
Description=Semaphore Ansible
Documentation=https://github.com/semaphoreui/semaphore
Wants=network-online.target
After=network-online.target
[Service]
Type=simple
ExecReload=/bin/kill -HUP $MAINPID
ExecStart=/usr/bin/semaphore server --config=/etc/semaphore/config.json
SyslogIdentifier=semaphore
Restart=always
RestartSec=10s
[Install]
WantedBy=multi-user.target
EOF
systemctl daemon-reload
firewall-cmd --add-port=3000/tcp --permanent
firewall-cmd --reload