This commit is contained in:
10
src/postinstall.sh
Normal file
10
src/postinstall.sh
Normal file
@@ -0,0 +1,10 @@
|
||||
#!/bin/bash
|
||||
|
||||
if command -v systemctl >/dev/null 2>&1; then
|
||||
systemctl daemon-reload || :
|
||||
if [ "$1" -eq 1 ]; then
|
||||
systemctl enable --now vctp.service || :
|
||||
else
|
||||
systemctl try-restart vctp.service || :
|
||||
fi
|
||||
fi
|
||||
8
src/postremove.sh
Normal file
8
src/postremove.sh
Normal file
@@ -0,0 +1,8 @@
|
||||
#!/bin/bash
|
||||
|
||||
if command -v systemctl >/dev/null 2>&1; then
|
||||
systemctl daemon-reload || :
|
||||
if [ "$1" -ge 1 ]; then
|
||||
systemctl try-restart vctp.service || :
|
||||
fi
|
||||
fi
|
||||
45
src/preinstall.sh
Normal file
45
src/preinstall.sh
Normal file
@@ -0,0 +1,45 @@
|
||||
#!/bin/bash
|
||||
USER="vctp"
|
||||
GROUP="dtms"
|
||||
|
||||
# Path to the custom sudoers file
|
||||
SUDOERS_FILE="/etc/sudoers.d/${USER}"
|
||||
|
||||
# create a group & user if not exists
|
||||
getent group "$GROUP" >/dev/null || groupadd -r "$GROUP"; /bin/true
|
||||
getent passwd "$USER" >/dev/null || useradd -r -g "$GROUP" -m -s /bin/bash -c "vctp service" "$USER"
|
||||
getent passwd tftp >/dev/null || useradd -r -g tftp -s /sbin/nologin tftp
|
||||
|
||||
# create vctp config directory if it doesn't exist
|
||||
[ -d /etc/dtms ] || mkdir -p /etc/dtms
|
||||
|
||||
# set group ownership on vctp config directory if not already done
|
||||
[ "$(stat -c "%G" /etc/dtms)" = "$GROUP" ] || chgrp -R "$GROUP" /etc/dtms
|
||||
|
||||
# set permissions on vctp config directory if not already done
|
||||
[ "$(stat -c "%a" /etc/dtms)" = "774" ] || chmod -R 774 /etc/dtms
|
||||
|
||||
# create vctp data directory if it doesn't exist
|
||||
[ -d /var/lib/vctp ] || mkdir -p /var/lib/vctp
|
||||
|
||||
# set user ownership on vctp data directory if not already done
|
||||
[ "$(stat -c "%U" /var/lib/vctp)" = "$USER" ] || chown -R "$USER" /var/lib/vctp
|
||||
|
||||
# set group ownership on vctp data directory if not already done
|
||||
[ "$(stat -c "%G" /var/lib/vctp)" = "$GROUP" ] || chgrp -R "$GROUP" /var/lib/vctp
|
||||
|
||||
# Check if firewalld is installed and active
|
||||
if command -v systemctl >/dev/null 2>&1 && systemctl is-enabled firewalld >/dev/null 2>&1 && systemctl is-active firewalld >/dev/null 2>&1; then
|
||||
echo "Firewalld is enabled and running. Adding necessary ports..."
|
||||
|
||||
# Open HTTPS port (443/tcp)
|
||||
firewall-cmd --permanent --add-service=https >/dev/null 2>&1
|
||||
|
||||
# Open custom application port (9443/tcp)
|
||||
firewall-cmd --permanent --add-port=9443/tcp >/dev/null 2>&1
|
||||
|
||||
# Reload firewalld to apply changes
|
||||
firewall-cmd --reload >/dev/null 2>&1
|
||||
else
|
||||
echo "Firewalld is not running or not enabled. Skipping firewall configuration."
|
||||
fi
|
||||
8
src/preremove.sh
Normal file
8
src/preremove.sh
Normal file
@@ -0,0 +1,8 @@
|
||||
#!/bin/bash
|
||||
|
||||
if command -v systemctl >/dev/null 2>&1; then
|
||||
if [ "$1" -eq 0 ]; then
|
||||
systemctl stop vctp.service || :
|
||||
systemctl disable vctp.service || :
|
||||
fi
|
||||
fi
|
||||
1
src/vctp.default
Normal file
1
src/vctp.default
Normal file
@@ -0,0 +1 @@
|
||||
CPE_OPTS='-config /etc/dtms/vctp.yml -log-level info -log-output text'
|
||||
21
src/vctp.service
Normal file
21
src/vctp.service
Normal file
@@ -0,0 +1,21 @@
|
||||
[Unit]
|
||||
Description=vCTP monitors VMware VM inventory and event data to build chargeback reports
|
||||
Documentation=https://gitlab.dell.com/
|
||||
ConditionPathExists=/usr/bin/vctp-linux-amd64
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
EnvironmentFile=/etc/default/vctp
|
||||
User=vctp
|
||||
ExecStart=/usr/bin/vctp-linux-amd64 $CPE_OPTS
|
||||
ExecStartPost=/usr/bin/sleep 3
|
||||
Restart=always
|
||||
RestartSec=10s
|
||||
#LimitNOFILE=65536
|
||||
SyslogIdentifier=vctp
|
||||
#CapabilityBoundingSet=CAP_NET_BIND_SERVICE CAP_FOWNER CAP_DAC_OVERRIDE CAP_SETUID CAP_SETGID CAP_SYS_RESOURCE CAP_AUDIT_WRITE
|
||||
#AmbientCapabilities=CAP_NET_BIND_SERVICE
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
25
src/vctp.yml
Normal file
25
src/vctp.yml
Normal file
@@ -0,0 +1,25 @@
|
||||
settings:
|
||||
data_location: "/var/lib/cbs"
|
||||
kickstart_location: "/var/lib/cbs/ks"
|
||||
database_filename: "/var/lib/cbs/cbs.db"
|
||||
bind_ip:
|
||||
bind_port: 443
|
||||
bind_disable_tls: false
|
||||
tls_cert_filename: "/etc/dtms/cbs.crt"
|
||||
tls_key_filename: "/etc/dtms/cbs.key"
|
||||
tftp_root_directory: "/var/lib/tftpboot"
|
||||
tftp_images_subdirectory: "images"
|
||||
replacements:
|
||||
omapi:
|
||||
key_name: "OMAPI"
|
||||
key_secret:
|
||||
special_files:
|
||||
ldap_groups:
|
||||
ldap_bind_address: ""
|
||||
ldap_base_dn: ""
|
||||
ldap_trust_cert_file: ""
|
||||
ldap_disable_validation: false
|
||||
ldap_insecure: false
|
||||
auth_token_lifespan_hours: 2
|
||||
auth_api_key: ""
|
||||
|
||||
Reference in New Issue
Block a user