Build Gitlab Runner Server CentOS8+VBox

Exported on 22-Jul-2021 23:14:16

This is Marcdown

  • Several
  • Bullet points

Parameters

Name Type Script Reference Default Value Comment
Docker: Registry Credential Generic Credential dockerRegistryCredential
Docker: Registry URL Text dockerRegistryUrl nexus.synerty.com:5000
Gitlab Runner Server Linux / Unix Server gitlabRunnerServer
Gitlab: Runner Token Generic Credential gitlabRunnerToken
Gitlab: Server URL Text gitlabServerUrl https://gitlab.synerty.com
KS Linux: Disk First Letter Text ksLinuxDiskFirstLetter s The first letter of the disk in Linux, EG, sda or xda
KS VBox: Guest Type Text ksVboxGuestType RedHat_64
KS: CPU Count Text ksCpuCount 2
KS: ISO Build Path Text ksIsoBuildPath VirtualBox/iso_build
KS: Memory Size Text ksMemorySize 2
Linux: Environment Name Text linuxEnvironmentName DEVOPS
Linux: Prompt Color Text linuxPromptColor 45m
Linux: Root User Linux OS Credential linuxRootUser
Mac Host Linux / Unix Server macHost
Mac User Linux OS Credential macUser
Target Environment Servers Server Group targetEnvironmentServers The servers in this group are added to the hosts file for this server being built
Target Server Generic Server targetServer
Target Server: Installer Tmp Path Text targetServerInstallerTmpPath /tmp/installers The temporary path used for installers that need to be copied to the server then installed.
Target Server: Lin Linux / Unix Server targetServerLin The target server is a generic placeholder, usually used for the server a script will run on. For example, the server being built if the procedure is building a server.
Target Server: Linux TimeZone Text targetServerLinuxTimezone Australia/Brisbane
Target Subnet IPv4 Subnet targetSubnet

1 - Kickstart CentOS8+VBox+macOS From DVD

This is a Linux Kickstart procedure for CentOS8 on macOS.

REQUIREMENTS:

  • VirtualBox
  • brew install cdrtools

1.1 - KS Clean Build Files

This step has the following parameters

Name Script Reference Default Value
KS: ISO Build Path {ksIsoBuildPath} VirtualBox/iso_build
Target Server {targetServer.fqn}
The connection details have changed from the last step.
Make sure you reconnect.

Login as user on node

Connect via SSH
ssh user@hostname
This is a Bash Script make sure you run it with bash -l from a terminal session

DIR="{ksIsoBuildPath}/*{targetServer.fqn}"
[ ! ${DIR} ] ||  rm -rf ${DIR}
 

1.2 - KS CentOS8 Deploy Binary DVD

This step has the following parameters

Name Script Reference Default Value
KS: ISO Build Path {ksIsoBuildPath} VirtualBox/iso_build
Target Server {targetServer.fqn}

Login as user on node

Connect via SSH
ssh user@hostname
Deploy archive CentOS Minimal DVD v8.2 (2004).tar to remote path {ksIsoBuildPath}/build-{targetServer.fqn}
  1. Locate Files archive "CentOS Minimal DVD v8.2 (2004).tar", This can be downloaded from Attune
  2. Copy the Files archive to the server
  3. Extract the root of the Files archive to {ksIsoBuildPath}/build-{targetServer.fqn}, relative to the home directory
  4. Check that the files are in the correct location

1.3 - KS CentOS8 Deploy Kickstart DVD Config

This step has the following parameters

Name Script Reference Default Value
KS: ISO Build Path {ksIsoBuildPath} VirtualBox/iso_build
Target Server {targetServer.fqn}

Login as user on node

Connect via SSH
ssh user@hostname
Deploy archive CentOS8 Kickstart DVD Config.tar to remote path {ksIsoBuildPath}/build-{targetServer.fqn}
  1. Locate Files archive "CentOS8 Kickstart DVD Config.tar", This can be downloaded from Attune
  2. Copy the Files archive to the server
  3. Extract the root of the Files archive to {ksIsoBuildPath}/build-{targetServer.fqn}, relative to the home directory
  4. Check that the files are in the correct location

1.4 - KS CentOS8 Create Binary DVD

This step has the following parameters

Name Script Reference Default Value
KS: ISO Build Path {ksIsoBuildPath} VirtualBox/iso_build
Target Server {targetServer.fqn}

Login as user on node

Connect via SSH
ssh user@hostname
This is a Bash Script make sure you run it with bash -l from a terminal session

if [ "`uname`" = "Darwin" ] && ! which mkisofs
then
    echo "For macOS, use homebrew and run" >&2
    echo "brew install cdrtools" >&2
    false
fi



cd ~/{ksIsoBuildPath}/build-{targetServer.fqn}

mkisofs -o ~/{ksIsoBuildPath}/kickstart_{targetServer.fqn}.iso \
  -b isolinux/isolinux.bin -c isolinux/boot.cat \
  -no-emul-boot -boot-load-size 4 -boot-info-table -J -R -V "KS_RHEL" .

rm -rvf ~/{ksIsoBuildPath}/build-{targetServer.fqn}
 

1.5 - KS VBox Recreate Virtual Machine

https://www.virtualbox.org/manual/ch08.html

1.5.1 - KS VBox Delete VM

This step has the following parameters

Name Script Reference Default Value
Target Server {targetServer.fqn}

Login as user on node

Connect via SSH
ssh user@hostname
This is a Bash Script make sure you run it with bash -l from a terminal session

VBOX_DIR="`echo ~/VirtualBox`"


if VBoxManage list vms | grep -q "{targetServer.fqn}"
then
    if VBoxManage list runningvms | grep -q "{targetServer.fqn}"
    then
        echo "Powering off VM"
        VBoxManage controlvm "{targetServer.fqn}" poweroff
        sleep 5s
    fi
    echo "Deleting VM"
    VBoxManage unregistervm "{targetServer.fqn}" --delete
fi


echo "Creating the VM"
VMDIR="${VBOX_DIR}/{targetServer.fqn}"
[ ! -d ${VMDIR} ] || rm -rvf ${VMDIR}
 

1.5.2 - KS VBox Create VM

Run the following to get the OS types

VBoxManage list ostypes

This step has the following parameters

Name Script Reference Default Value
KS VBox: Guest Type {ksVboxGuestType} RedHat_64
KS: CPU Count {ksCpuCount} 2
KS: Memory Size {ksMemorySize} 2
Target Server {targetServer.fqn}

Login as user on node

Connect via SSH
ssh user@hostname
This is a Bash Script make sure you run it with bash -l from a terminal session

VBOX_DIR="`echo ~/VirtualBox`"

[ -d ${VBOX_DIR} ] || mkdir -pv ${VBOX_DIR}

echo "Creating the VM"
VBoxManage createvm --name "{targetServer.fqn}" \
    --ostype "{ksVboxGuestType}" \
    --register \
    --basefolder ${VBOX_DIR}
    
    
VBoxManage modifyvm "{targetServer.fqn}" --cpus {ksCpuCount}

echo "Configure the RAM for hte VM"
VBoxManage modifyvm "{targetServer.fqn}" --ioapic on
VBoxManage modifyvm "{targetServer.fqn}" --memory $(({ksMemorySize}*1024)) \
    --vram 128

echo "Adding a network adaptor"
VBoxManage modifyvm "{targetServer.fqn}" --nic1 bridged \
    --bridgeadapter1 en0
#VBoxManage modifyvm "{targetServer.fqn}" --nic1 nat

echo "Creating IDE and SATA disks"

VBoxManage storagectl "{targetServer.fqn}" \
    --name "SATA Controller" \
    --add sata \
    --controller IntelAhci

VBoxManage storagectl "{targetServer.fqn}" \
    --name "IDE Controller" \
    --add ide \
    --controller PIIX4
 

1.5.3 - KS VBox Create Disk

This step has the following parameters

Name Script Reference Default Value
Target Server {targetServer.fqn}

Login as user on node

Connect via SSH
ssh user@hostname
This is a Bash Script make sure you run it with bash -l from a terminal session

VBOX_DIR="`echo ~/VirtualBox`"

DISK="${VBOX_DIR}/{targetServer.fqn}/disk_1.vdi"

VBoxManage createhd \
    --filename ${DISK} \
    --size $((50 * 1024)) \
    --format VDI                     


VBoxManage storageattach "{targetServer.fqn}" \
    --storagectl "SATA Controller" \
    --port 0 \
    --device 0 \
    --type hdd \
    --medium  ${DISK}
 

1.5.4 - KS VBox Load ISO into VM

NOTE: The kickstart script ejects this CDROM

This step has the following parameters

Name Script Reference Default Value
KS: ISO Build Path {ksIsoBuildPath} VirtualBox/iso_build
Target Server {targetServer.fqn}

Login as user on node

Connect via SSH
ssh user@hostname
This is a Bash Script make sure you run it with bash -l from a terminal session

echo "Creating and Attaching DVD"
VBoxManage storageattach "{targetServer.fqn}" \
    --storagectl "IDE Controller" \
    --port 1 \
    --device 0 \
    --type dvddrive \
    --medium ~/{ksIsoBuildPath}/kickstart_{targetServer.fqn}.iso

# Change medium to "emptydrive" to unload the disk

    
echo "Setting Boot Order"
VBoxManage modifyvm "{targetServer.fqn}" \
    --boot1 disk \
    --boot2 dvd \
    --boot3 none \
    --boot4 none
 

1.5.5 - KS VBox Start VM

This step has the following parameters

Name Script Reference Default Value
Target Server {targetServer.fqn}

Login as user on node

Connect via SSH
ssh user@hostname
This is a Bash Script make sure you run it with bash -l from a terminal session

echo "Starting the VM"
VBoxManage startvm "{targetServer.fqn}" --type gui
 

1.6 - KS Clean Build Files

This step has the following parameters

Name Script Reference Default Value
KS: ISO Build Path {ksIsoBuildPath} VirtualBox/iso_build
Target Server {targetServer.fqn}

Login as user on node

Connect via SSH
ssh user@hostname
This is a Bash Script make sure you run it with bash -l from a terminal session

DIR="{ksIsoBuildPath}/*{targetServer.fqn}"
[ ! ${DIR} ] ||  rm -rf ${DIR}
 

1.7 - KS SSH Wait

The connection details have changed from the last step.
Make sure you reconnect.

on node

Check if tcp port 22 is listening once its up, wait 5 seconds .

Use Telnet to check if the TCP service is accepting connections.

2 - VBox Setup GitlabRunner Disks

2.1 - KS VBox Stop VM

This step has the following parameters

Name Script Reference Default Value
Target Server {targetServer.fqn}
The connection details have changed from the last step.
Make sure you reconnect.

Login as user on node

Connect via SSH
ssh user@hostname
This is a Bash Script make sure you run it with bash -l from a terminal session

echo "Powering off VM"
VBoxManage controlvm "{targetServer.fqn}" poweroff
sleep 5s
 

2.2 - VBox Create GitlabRunner Disk

This step has the following parameters

Name Script Reference Default Value
Target Server {targetServer.fqn}

Login as user on node

Connect via SSH
ssh user@hostname
This is a Bash Script make sure you run it with bash -l from a terminal session

VBOX_DIR="`echo ~/VirtualBox`"

DISK="${VBOX_DIR}/{targetServer.fqn}/disk_2.vdi"

VBoxManage createhd \
    --filename ${DISK} \
    --size $((200 * 1024)) \
    --format VDI                     


VBoxManage storageattach "{targetServer.fqn}" \
    --storagectl "SATA Controller" \
    --port 1 \
    --device 0 \
    --type hdd \
    --medium  ${DISK}
 

2.3 - KS VBox Start VM

This step has the following parameters

Name Script Reference Default Value
Target Server {targetServer.fqn}

Login as user on node

Connect via SSH
ssh user@hostname
This is a Bash Script make sure you run it with bash -l from a terminal session

echo "Starting the VM"
VBoxManage startvm "{targetServer.fqn}" --type gui
 

2.4 - KS SSH Wait

The connection details have changed from the last step.
Make sure you reconnect.

on node

Check if tcp port 22 is listening once its up, wait 5 seconds .

Use Telnet to check if the TCP service is accepting connections.

3 - CentOS8 Setup Gitlab Runner LVM

3.1 - GLRUN Setup VGs

This step has the following parameters

Name Script Reference Default Value
KS Linux: Disk First Letter {ksLinuxDiskFirstLetter} s
The connection details have changed from the last step.
Make sure you reconnect.

Login as user on node

Connect via SSH
ssh user@hostname
This is a Bash Script make sure you run it with bash -l from a terminal session

mkvg() {
    VG=$1
    DEV=$2
    
    parted -s /dev/$DEV mktable gpt
    parted -s /dev/$DEV mkpart primary xfs 1m 100%
    
    vgextend $VG /dev/${DEV}1
    
}

mkvg rootvg {ksLinuxDiskFirstLetter}db
 

3.2 - GLRUN Setup Docker LV

Login as user on node

Connect via SSH
ssh user@hostname
This is a Bash Script make sure you run it with bash -l from a terminal session

mklv() {
    DIR=$1
    NAME=$2
    SIZE=$3
    VG=$4
    
    mkdir -p $DIR
    lvcreate --size $SIZE --name $NAME $VG 
    mkfs.xfs /dev/mapper/$VG-$NAME
    
    cat >> /etc/fstab <<EOF
/dev/mapper/$VG-$NAME    $DIR                    xfs     defaults        0 0
EOF
    mount -a
}

mklv /var/lib/docker docker 100g rootvg
 

4 - Build Gitlab Runner Server

4.1 - RHEL8 SOS Install Utilities

Install package updates and common dependencies for PowerOn Fusion DPF, TSDS, Database, Application or Report servers.

4.1.1 - PONR8 PU Install Net-Tools

The connection details have changed from the last step.
Make sure you reconnect.

Login as user on node

Connect via SSH
ssh user@hostname
This is a Bash Script make sure you run it with bash -l from a terminal session

yum install -y net-tools
 

4.1.2 - PONR8 PU Install Git

Login as user on node

Connect via SSH
ssh user@hostname
This is a Bash Script make sure you run it with bash -l from a terminal session

yum install -y git
 

4.1.3 - PONR8 PU Install Tar

Login as user on node

Connect via SSH
ssh user@hostname
This is a Bash Script make sure you run it with bash -l from a terminal session

yum install -y tar
 

4.1.4 - PONR8 PU Install Bzip2

Login as user on node

Connect via SSH
ssh user@hostname
This is a Bash Script make sure you run it with bash -l from a terminal session

yum install -y bzip2
 

4.1.5 - PONR8 PU Install Unzip

Login as user on node

Connect via SSH
ssh user@hostname
This is a Bash Script make sure you run it with bash -l from a terminal session

yum install -y unzip
 

4.1.6 - PONR8 PU Install Rsync

Login as user on node

Connect via SSH
ssh user@hostname
This is a Bash Script make sure you run it with bash -l from a terminal session

yum install -y rsync
 

4.1.7 - PONR8 PU Install Telnet

Login as user on node

Connect via SSH
ssh user@hostname
This is a Bash Script make sure you run it with bash -l from a terminal session

yum install -y telnet
 

4.1.8 - PONR8 PU Install NC

Login as user on node

Connect via SSH
ssh user@hostname
This is a Bash Script make sure you run it with bash -l from a terminal session

dnf install -y nc
 

4.1.9 - PONR8 PU Install Wireshark

Login as user on node

Connect via SSH
ssh user@hostname
This is a Bash Script make sure you run it with bash -l from a terminal session

yum install -y wireshark
 

4.1.10 - PONR8 PU Install Nano

Login as user on node

Connect via SSH
ssh user@hostname
This is a Bash Script make sure you run it with bash -l from a terminal session

yum install -y nano
 

4.1.11 - PONR8 PU Deploy nmon

This step has the following parameters

Name Script Reference Default Value
Target Server: Installer Tmp Path {targetServerInstallerTmpPath} /tmp/installers

Login as user on node

Connect via SSH
ssh user@hostname
Deploy archive RHEL8 EPEL nmon.tar to remote path {targetServerInstallerTmpPath}
  1. Locate Files archive "RHEL8 EPEL nmon.tar", This can be downloaded from Attune
  2. Copy the Files archive to the server
  3. Extract the root of the Files archive to {targetServerInstallerTmpPath}, relative to the home directory
  4. Check that the files are in the correct location

4.1.12 - PONR8 PU Install nmon

This step has the following parameters

Name Script Reference Default Value
Target Server: Installer Tmp Path {targetServerInstallerTmpPath} /tmp/installers

Login as user on node

Connect via SSH
ssh user@hostname
This is a Bash Script make sure you run it with bash -l from a terminal session

D={targetServerInstallerTmpPath}/pkg_nmon

yum install -y $D/nmon*rpm

rm -rf $D
 

4.1.13 - PONR8 PU Deploy iftop

This step has the following parameters

Name Script Reference Default Value
Target Server: Installer Tmp Path {targetServerInstallerTmpPath} /tmp/installers

Login as user on node

Connect via SSH
ssh user@hostname
Deploy archive RHEL8 EPEL iftop.tar to remote path {targetServerInstallerTmpPath}
  1. Locate Files archive "RHEL8 EPEL iftop.tar", This can be downloaded from Attune
  2. Copy the Files archive to the server
  3. Extract the root of the Files archive to {targetServerInstallerTmpPath}, relative to the home directory
  4. Check that the files are in the correct location

4.1.14 - PONR8 PU Install iftop

This step has the following parameters

Name Script Reference Default Value
Target Server: Installer Tmp Path {targetServerInstallerTmpPath} /tmp/installers

Login as user on node

Connect via SSH
ssh user@hostname
This is a Bash Script make sure you run it with bash -l from a terminal session

D={targetServerInstallerTmpPath}/pkg_iftop

yum install -y $D/iftop*rpm

rm -rf $D
 

4.1.15 - PONR8 PU Deploy p7zip

This step has the following parameters

Name Script Reference Default Value
Target Server: Installer Tmp Path {targetServerInstallerTmpPath} /tmp/installers

Login as user on node

Connect via SSH
ssh user@hostname
Deploy archive RHEL8 EPEL p7zip.tar to remote path {targetServerInstallerTmpPath}
  1. Locate Files archive "RHEL8 EPEL p7zip.tar", This can be downloaded from Attune
  2. Copy the Files archive to the server
  3. Extract the root of the Files archive to {targetServerInstallerTmpPath}, relative to the home directory
  4. Check that the files are in the correct location

4.1.16 - PONR8 PU Install p7zip

This step has the following parameters

Name Script Reference Default Value
Target Server: Installer Tmp Path {targetServerInstallerTmpPath} /tmp/installers

Login as user on node

Connect via SSH
ssh user@hostname
This is a Bash Script make sure you run it with bash -l from a terminal session

D={targetServerInstallerTmpPath}/pkg_p7zip

yum install -y $D/p7zip*rpm

rm -rf $D
 

4.2 - RHEL8 SOS Configure OS

4.2.1 - PONR8 COS Deploy OS Config Files

Login as user on node

Connect via SSH
ssh user@hostname
Deploy archive RHEL8 STD etc Configs.tar to remote path /
  1. Locate Files archive "RHEL8 STD etc Configs.tar", This can be downloaded from Attune
  2. Copy the Files archive to the server
  3. Extract the root of the Files archive to /
  4. Check that the files are in the correct location

4.2.2 - PONR8 COS Fix OS Config Permissions

Login as user on node

Connect via SSH
ssh user@hostname
This is a Bash Script make sure you run it with bash -l from a terminal session

chmod ugo+r /etc/profile.d/environment_prompt.sh

chmod ugo+r /etc/hosts
 

4.2.3 - PON RHEL8 Set Hostname

This step has the following parameters

Name Script Reference Default Value
Target Server {targetServer.hostname} None

Login as user on node

Connect via SSH
ssh user@hostname
This is a Bash Script make sure you run it with bash -l from a terminal session

echo "{targetServer.hostname}" > /etc/hostname

hostname "{targetServer.hostname}"
 

4.2.4 - PON RHEL8 Disable IPv6

Login as user on node

Connect via SSH
ssh user@hostname
This is a Bash Script make sure you run it with bash -l from a terminal session

F="/etc/sysctl.conf"

if grep -q 'net.ipv6' ${F}; then
    echo "IPv6 is already disabled"
else
    echo "Disabling IPv6"
    echo "" >> $F
    echo "# Disable IPv6" >> $F
    echo "net.ipv6.conf.all.disable_ipv6 = 1" >> $F
    echo "net.ipv6.conf.default.disable_ipv6 = 1" >> $F
    sysctl -p
fi

sed -i '/::1/d' /etc/hosts
 

4.2.5 - PONR8 COS Setup Login Banner

Login as user on node

Connect via SSH
ssh user@hostname
This is a Bash Script make sure you run it with bash -l from a terminal session

chmod 644 /etc/login_banner

sed -i 's,# Banner.*,Banner /etc/login_banner,g' /etc/ssh/sshd_config

systemctl restart sshd
 

4.3 - RHEL8 GLRUN Install Docker

The connection details have changed from the last step.
Make sure you reconnect.

Login as user on node

Connect via SSH
ssh user@hostname
This is a Bash Script make sure you run it with bash -l from a terminal session

sudo yum install -y yum-utils

sudo yum-config-manager \
    --add-repo \
    https://download.docker.com/linux/centos/docker-ce.repo
    
sudo yum install -y docker-ce docker-ce-cli containerd.io

systemctl enable --now docker
 

4.4 - RHEL8 GLRUN Enable Insecure Registry

This step has the following parameters

Name Script Reference Default Value
Docker: Registry URL {dockerRegistryUrl} nexus.synerty.com:5000

Login as user on node

Connect via SSH
ssh user@hostname
This is a Bash Script make sure you run it with bash -l from a terminal session

cat <<EOF > /etc/docker/daemon.json

{
  "insecure-registries" : ["{dockerRegistryUrl}"],
  "registry-mirrors": ["http://{dockerRegistryUrl}"]
}

EOF

systemctl restart docker
 

4.5 - RHEL8 GLRUN Login to Registry

This step has the following parameters

Name Script Reference Default Value
Docker: Registry URL {dockerRegistryUrl} nexus.synerty.com:5000
Docker: Registry Credential {dockerRegistryCredential.password} None
Docker: Registry Credential {dockerRegistryCredential.user} None

Login as user on node

Connect via SSH
ssh user@hostname
This is a Bash Script make sure you run it with bash -l from a terminal session

docker login {dockerRegistryUrl}
 

This step will require you to answer the following prompts.

Prompt Answer
Username: {dockerRegistryCredential.user}
Password: {dockerRegistryCredential.password}

4.6 - RHEL8 GLRUN Install Gitlab Runner

Login as user on node

Connect via SSH
ssh user@hostname
This is a Bash Script make sure you run it with bash -l from a terminal session

URL='https://packages.gitlab.com/install/repositories/runner/gitlab-runner/script.rpm.sh'

curl -L $URL | sudo bash

sudo yum install -y gitlab-runner
 

4.7 - RHEL8 GLRUN Register Runner

This step has the following parameters

Name Script Reference Default Value
Gitlab: Server URL {gitlabServerUrl} https://gitlab.synerty.com
Gitlab: Runner Token {gitlabRunnerToken.password} None
Gitlab Runner Server {gitlabRunnerServer.fqn}

Login as user on node

Connect via SSH
ssh user@hostname
This is a Bash Script make sure you run it with bash -l from a terminal session

F="/etc/gitlab-runner/config.toml"

pkill -f gitlab-runner || true

[ ! -f $F ] || rm $F

gitlab-runner register \
    --custom_build_dir-enabled \
    --executor docker \
    --docker-image debian:10 \
    --docker-volumes "/cache" \
    --docker-volumes "/var/run/docker.sock:/var/run/docker.sock" \
    --docker-volumes "/usr/bin/docker:/usr/bin/docker" 

    

# Update teh concurrency
sed -i 's/concurrent.*/concurrent = 2/g' $F

chgrp gitlab-runner $F
 

This step will require you to answer the following prompts.

Prompt Answer
Enter the GitLab instance URL (for example, https://gitlab.com/): {gitlabServerUrl}
Enter the registration token: {gitlabRunnerToken.password}
Enter a description for the runner: {gitlabRunnerServer.fqn}
Enter tags for the runner (comma-separated): linux
[docker]:
[debian:10]:

4.8 - RHEL8 GLRUN Start Runner

Login as user on node

Connect via SSH
ssh user@hostname
This is a Bash Script make sure you run it with bash -l from a terminal session

systemctl enable gitlab-runner --now
 

4.9 - LIN Reboot

The connection details have changed from the last step.
Make sure you reconnect.

Login as user on node

Connect via SSH
ssh user@hostname
This is a Bash Script make sure you run it with bash -l from a terminal session

nohup shutdown -r now &
 

4.10 - LIN Reboot Wait

The connection details have changed from the last step.
Make sure you reconnect.

on node

Check if tcp port 22 is listening make sure it goes down for 3 seconds, once its up, wait 10 seconds .

Use Telnet to check if the TCP service is accepting connections.