summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordd <dd@wx.tnyzeq.icu>2024-08-04 13:08:22 +0200
committerdd <dd@wx.tnyzeq.icu>2024-08-04 13:08:22 +0200
commit3631bcca58b34d3857d42b8c5941ea2234c0be89 (patch)
treea6164565888f9255c1f311e0f076805035f813b4
parent36cf68f9fd34e02bc8f40df529c1f2f4d757df7b (diff)
downloadvyos-jenkins-3631bcca58b34d3857d42b8c5941ea2234c0be89.tar.gz
vyos-jenkins-3631bcca58b34d3857d42b8c5941ea2234c0be89.zip
fixed uncron service and updated 4-uncron.sh to allow uncron updates
-rwxr-xr-x4-uncron.sh67
-rwxr-xr-xauto/uncron-script.sh5
-rw-r--r--auto/uncron.service1
3 files changed, 35 insertions, 38 deletions
diff --git a/4-uncron.sh b/4-uncron.sh
index cd961c2..e18b4e6 100755
--- a/4-uncron.sh
+++ b/4-uncron.sh
@@ -15,6 +15,9 @@ EnsureStageIsComplete 3
cp ./auto/uncron-script.sh /var/lib/jenkins
chown jenkins:jenkins /var/lib/jenkins/uncron-script.sh
+# Stop if already running
+systemctl stop uncron.service > /dev/null 2>&1
+
# This script builds the uncron package.
echo "Running uncron script as jenkins user..."
runuser -l jenkins -c "./uncron-script.sh"
@@ -24,50 +27,38 @@ rm /var/lib/jenkins/uncron-script.sh > /dev/null 2>&1
#endregion
#region Copy uncron into sbin
-if [ -f /usr/local/sbin/uncron ]; then
- PrintOkIndicator "Uncron has already been installed."
-else
- function InstallUncron {
- cp /var/lib/jenkins/uncron/_build/install/default/bin/uncron /usr/local/sbin/
- }
-
- Run "InstallUncron" \
- "Installing Uncron..." \
- "Failed to install Uncron." \
- "Uncron has been installed."
-fi
+function InstallUncron {
+ cp /var/lib/jenkins/uncron/_build/install/default/bin/uncron /usr/local/sbin/
+}
+
+Run "InstallUncron" \
+ "Installing Uncron..." \
+ "Failed to install Uncron." \
+ "Uncron has been installed."
#endregion
#region Setup systemd service file
-if [ -f /etc/systemd/system/uncron.service ]; then
- PrintOkIndicator "SystemD service file has already been copied."
-else
- function CopySystemDServiceFile {
- cp ./auto/uncron.service /etc/systemd/system
- }
-
- Run "CopySystemDServiceFile" \
- "Copying SystemD service file..." \
- "Failed to copy SystemD service file." \
- "SystemD file has been copied."
-fi
+function CopySystemDServiceFile {
+ cp ./auto/uncron.service /etc/systemd/system
+}
+
+Run "CopySystemDServiceFile" \
+ "Copying SystemD service file..." \
+ "Failed to copy SystemD service file." \
+ "SystemD file has been copied."
#endregion
#region Install Uncron Add
-if [ -f /usr/local/bin/uncron-add ]; then
- PrintOkIndicator "Uncron Add has already been installed."
-else
- function InstallUncronAdd {
- cp ./auto/uncron-add /usr/local/bin
- chmod +x /usr/local/bin/uncron-add
- chmod +x /var/lib/jenkins/uncron/src/uncron-add
- }
-
- Run "InstallUncronAdd" \
- "Installing Uncron Add..." \
- "Failed to install Uncron Add." \
- "Uncron Add has been installed."
-fi
+function InstallUncronAdd {
+ cp ./auto/uncron-add /usr/local/bin
+ chmod +x /usr/local/bin/uncron-add
+ chmod +x /var/lib/jenkins/uncron/src/uncron-add
+}
+
+Run "InstallUncronAdd" \
+ "Installing Uncron Add..." \
+ "Failed to install Uncron Add." \
+ "Uncron Add has been installed."
#endregion
#region Uncron config
diff --git a/auto/uncron-script.sh b/auto/uncron-script.sh
index a8df081..c426459 100755
--- a/auto/uncron-script.sh
+++ b/auto/uncron-script.sh
@@ -10,6 +10,7 @@ fi
if [ -d uncron ]; then
echo "Updating Uncron git repository..."
cd uncron
+ git reset --hard origin/main > /dev/null 2>&1 # revert patches
git pull > /dev/null 2>&1
else
echo "Cloning Uncron git repository..."
@@ -31,5 +32,9 @@ opam install lwt lwt_ppx logs containers -y > /dev/null 2>&1
eval $(opam env)
+echo "Applying patches..."
+sed -i 's~/run/uncron.sock~/run/uncron/uncron.sock~' src/uncron-add
+sed -i 's~/run/uncron.sock~/run/uncron/uncron.sock~' src/uncron.ml
+
echo "Building Uncron..."
dune build
diff --git a/auto/uncron.service b/auto/uncron.service
index 8f3290a..67471a9 100644
--- a/auto/uncron.service
+++ b/auto/uncron.service
@@ -11,6 +11,7 @@ User=jenkins
Group=jenkins
Restart=on-failure
RestartSec=5s
+RuntimeDirectory=uncron
[Install]
WantedBy=multi-user.target