-
Notifications
You must be signed in to change notification settings - Fork 0
/
orijen-udf-base-install.sh
executable file
·49 lines (39 loc) · 1.2 KB
/
orijen-udf-base-install.sh
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
#!/bin/bash
# Update apt
sudo DEBIAN_FRONTEND=noninteractive apt-get update --yes
# Check if Docker is installed, install it if it's not
if ! command -v docker &> /dev/null
then
echo "Docker could not be found, installing..."
sudo apt-get install -y docker.io
fi
# Enable and start Docker
sudo systemctl enable docker
sudo systemctl start docker
# Variable Declarations
IMAGE=ghcr.io/f5devcentral/orijen-udf-service/orijen-udf-base:latest
SERVICE=orijen-udf-base.service
CONTAINER=orijen-udf-base
# Create the systemd service file
sudo bash -c "cat > /etc/systemd/system/$SERVICE <<EOF
[Unit]
Description=Orijen UDF Service
Requires=docker.service
After=docker.service
[Service]
TimeoutStartSec=0
Restart=always
ExecStartPre=-/usr/bin/docker stop $IMAGE
ExecStartPre=-/usr/bin/docker rm $IMAGE
ExecStartPre=/usr/bin/docker pull $IMAGE
ExecStart=/usr/bin/docker run --rm --name $CONTAINER $IMAGE
ExecStop=/usr/bin/docker stop $CONTAINER
[Install]
WantedBy=multi-user.target
EOF"
# Reload systemd manager configuration
sudo systemctl daemon-reload
# Enable and start your app service
sudo systemctl enable $SERVICE
sudo systemctl start $SERVICE
echo "$SERVICE has been installed and started as a systemd service."