summaryrefslogtreecommitdiff
path: root/4-uncron.sh
blob: e18b4e63af6fa09518cd625db61485440c00c1e0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#!/usr/bin/env bash

source ./auto/helper-logic

# Clear the screen and print the header
PrintHeader

# Ensure we are running as root
EnsureRoot

# Ensure stage 3 is complete
EnsureStageIsComplete 3

#region Run Uncron script
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"
echo

rm /var/lib/jenkins/uncron-script.sh > /dev/null 2>&1
#endregion

#region Copy uncron into sbin
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
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
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
if [ ! -f /etc/uncron.conf ]; then
  touch /etc/uncron.conf
fi
#endregion

# Reload daemons.
systemctl daemon-reload > /dev/null 2>&1

# Ensure uncron service is enabled.
systemctl enable --now uncron.service > /dev/null 2>&1

echo
echo "Part 4 of the installer is now done."
echo "Please run part five (5-docker-jobs.sh) to set up the vyos build container jobs."

# Create marker file
CreateMarkerFile 4