forked from vitalif/vitastor
Add vitastor-mon.service, vitastor.target, create user and log directory during package installation
parent
68ebe5993a
commit
bd11db5d0a
|
@ -1 +1,2 @@
|
||||||
mon usr/lib/vitastor
|
mon usr/lib/vitastor
|
||||||
|
mon/vitastor-mon.service /lib/systemd/system
|
||||||
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
if [ "$1" = "configure" ]; then
|
||||||
|
addgroup --system --quiet vitastor
|
||||||
|
adduser --system --quiet --ingroup vitastor --no-create-home --home /nonexistent vitastor
|
||||||
|
fi
|
|
@ -2,4 +2,5 @@ usr/bin/vitastor-osd
|
||||||
usr/bin/vitastor-disk
|
usr/bin/vitastor-disk
|
||||||
usr/bin/vitastor-dump-journal
|
usr/bin/vitastor-dump-journal
|
||||||
mon/vitastor-osd@.service /lib/systemd/system
|
mon/vitastor-osd@.service /lib/systemd/system
|
||||||
|
mon/vitastor.target /lib/systemd/system
|
||||||
mon/90-vitastor.rules /lib/udev/rules.d
|
mon/90-vitastor.rules /lib/udev/rules.d
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
if [ "$1" = "configure" ]; then
|
||||||
|
addgroup --system --quiet vitastor
|
||||||
|
adduser --system --quiet --ingroup vitastor --no-create-home --home /nonexistent vitastor
|
||||||
|
install -o vitastor -g vitastor -d /var/log/vitastor
|
||||||
|
fi
|
|
@ -1,13 +1,12 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# Very simple systemd unit generator for etcd & vitastor-mon services
|
# Simple systemd unit generator for etcd
|
||||||
# Not the final solution yet, mostly for tests
|
|
||||||
# Copyright (c) Vitaliy Filippov, 2019+
|
# Copyright (c) Vitaliy Filippov, 2019+
|
||||||
# License: MIT
|
# License: MIT
|
||||||
|
|
||||||
# USAGE: ./make-units.sh
|
# USAGE: [IP_SUBSTR=10.200.1.] [ETCD_HOSTS=etcd0=http://10.200.1.10:2380,...] ./make-etcd.sh
|
||||||
|
|
||||||
IP_SUBSTR="10.200.1."
|
IP_SUBSTR=${IP_SUBSTR:-10.200.1.}
|
||||||
ETCD_HOSTS="etcd0=http://10.200.1.10:2380,etcd1=http://10.200.1.11:2380,etcd2=http://10.200.1.12:2380"
|
ETCD_HOSTS=${ETCD_HOSTS:-etcd0=http://10.200.1.10:2380,etcd1=http://10.200.1.11:2380,etcd2=http://10.200.1.12:2380}
|
||||||
|
|
||||||
# determine IP
|
# determine IP
|
||||||
IP=`ip -json a s | jq -r '.[].addr_info[] | select(.local | startswith("'$IP_SUBSTR'")) | .local'`
|
IP=`ip -json a s | jq -r '.[].addr_info[] | select(.local | startswith("'$IP_SUBSTR'")) | .local'`
|
||||||
|
@ -16,7 +15,6 @@ ETCD_NUM=${ETCD_HOSTS/$IP*/}
|
||||||
[ "$ETCD_NUM" != "$ETCD_HOSTS" ] || exit 1
|
[ "$ETCD_NUM" != "$ETCD_HOSTS" ] || exit 1
|
||||||
ETCD_NUM=$(echo $ETCD_NUM | tr -d -c , | wc -c)
|
ETCD_NUM=$(echo $ETCD_NUM | tr -d -c , | wc -c)
|
||||||
|
|
||||||
# etcd
|
|
||||||
useradd etcd
|
useradd etcd
|
||||||
|
|
||||||
mkdir -p /var/lib/etcd$ETCD_NUM.etcd
|
mkdir -p /var/lib/etcd$ETCD_NUM.etcd
|
||||||
|
@ -50,37 +48,3 @@ EOF
|
||||||
systemctl daemon-reload
|
systemctl daemon-reload
|
||||||
systemctl enable etcd
|
systemctl enable etcd
|
||||||
systemctl start etcd
|
systemctl start etcd
|
||||||
|
|
||||||
useradd vitastor
|
|
||||||
chmod 755 /root
|
|
||||||
|
|
||||||
# Vitastor target
|
|
||||||
cat >/etc/systemd/system/vitastor.target <<EOF
|
|
||||||
[Unit]
|
|
||||||
Description=vitastor target
|
|
||||||
[Install]
|
|
||||||
WantedBy=multi-user.target
|
|
||||||
EOF
|
|
||||||
|
|
||||||
# Monitor unit
|
|
||||||
ETCD_MON=$(echo $ETCD_HOSTS | perl -pe 's/:2380/:2379/g; s/etcd\d*=//g;')
|
|
||||||
cat >/etc/systemd/system/vitastor-mon.service <<EOF
|
|
||||||
[Unit]
|
|
||||||
Description=Vitastor monitor
|
|
||||||
After=network-online.target local-fs.target time-sync.target
|
|
||||||
Wants=network-online.target local-fs.target time-sync.target
|
|
||||||
|
|
||||||
[Service]
|
|
||||||
Restart=always
|
|
||||||
ExecStart=node /usr/lib/vitastor/mon/mon-main.js --etcd_url '$ETCD_MON' --etcd_prefix '/vitastor' --etcd_start_timeout 5
|
|
||||||
WorkingDirectory=/
|
|
||||||
User=vitastor
|
|
||||||
PrivateTmp=false
|
|
||||||
TasksMax=infinity
|
|
||||||
Restart=always
|
|
||||||
StartLimitInterval=0
|
|
||||||
RestartSec=10
|
|
||||||
|
|
||||||
[Install]
|
|
||||||
WantedBy=vitastor.target
|
|
||||||
EOF
|
|
|
@ -12,7 +12,7 @@ for (let i = 2; i < process.argv.length; i++)
|
||||||
if (process.argv[i] === '-h' || process.argv[i] === '--help')
|
if (process.argv[i] === '-h' || process.argv[i] === '--help')
|
||||||
{
|
{
|
||||||
console.error('USAGE: '+process.argv[0]+' '+process.argv[1]+' [--verbose 1]'+
|
console.error('USAGE: '+process.argv[0]+' '+process.argv[1]+' [--verbose 1]'+
|
||||||
' [--etcd_address "http://127.0.0.1:2379,..."] [--config_file /etc/vitastor/vitastor.conf]'+
|
' [--etcd_address "http://127.0.0.1:2379,..."] [--config_path /etc/vitastor/vitastor.conf]'+
|
||||||
' [--etcd_prefix "/vitastor"] [--etcd_start_timeout 5]');
|
' [--etcd_prefix "/vitastor"] [--etcd_start_timeout 5]');
|
||||||
process.exit();
|
process.exit();
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,18 @@
|
||||||
|
[Unit]
|
||||||
|
Description=Vitastor monitor
|
||||||
|
After=network-online.target local-fs.target time-sync.target
|
||||||
|
Wants=network-online.target local-fs.target time-sync.target
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Restart=always
|
||||||
|
ExecStart=node /usr/lib/vitastor/mon/mon-main.js
|
||||||
|
WorkingDirectory=/
|
||||||
|
User=vitastor
|
||||||
|
PrivateTmp=false
|
||||||
|
TasksMax=infinity
|
||||||
|
Restart=always
|
||||||
|
StartLimitInterval=0
|
||||||
|
RestartSec=10
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=vitastor.target
|
|
@ -0,0 +1,4 @@
|
||||||
|
[Unit]
|
||||||
|
Description=vitastor target
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
|
@ -106,7 +106,7 @@ cd ..
|
||||||
mkdir -p %buildroot/usr/lib/vitastor
|
mkdir -p %buildroot/usr/lib/vitastor
|
||||||
cp -r mon %buildroot/usr/lib/vitastor
|
cp -r mon %buildroot/usr/lib/vitastor
|
||||||
mkdir -p %buildroot/lib/systemd/system
|
mkdir -p %buildroot/lib/systemd/system
|
||||||
cp mon/vitastor-osd@.service %buildroot/lib/systemd/system
|
cp mon/vitastor.target mon/vitastor-mon.service mon/vitastor-osd@.service %buildroot/lib/systemd/system
|
||||||
mkdir -p %buildroot/lib/udev/rules.d
|
mkdir -p %buildroot/lib/udev/rules.d
|
||||||
cp mon/90-vitastor.rules %buildroot/lib/udev/rules.d
|
cp mon/90-vitastor.rules %buildroot/lib/udev/rules.d
|
||||||
|
|
||||||
|
@ -120,11 +120,24 @@ cp mon/90-vitastor.rules %buildroot/lib/udev/rules.d
|
||||||
%_bindir/vitastor-disk
|
%_bindir/vitastor-disk
|
||||||
%_bindir/vitastor-dump-journal
|
%_bindir/vitastor-dump-journal
|
||||||
/lib/systemd/system/vitastor-osd@.service
|
/lib/systemd/system/vitastor-osd@.service
|
||||||
|
/lib/systemd/system/vitastor.target
|
||||||
/lib/udev/rules.d/90-vitastor.rules
|
/lib/udev/rules.d/90-vitastor.rules
|
||||||
|
|
||||||
|
|
||||||
|
%pre -n vitastor-osd
|
||||||
|
groupadd -r -f vitastor 2>/dev/null ||:
|
||||||
|
useradd -r -g vitastor -s /sbin/nologin -c "Vitastor daemons" -M -d /nonexistent vitastor 2>/dev/null ||:
|
||||||
|
install -o vitastor -g vitastor -d /var/log/vitastor
|
||||||
|
|
||||||
|
|
||||||
%files -n vitastor-mon
|
%files -n vitastor-mon
|
||||||
/usr/lib/vitastor/mon
|
/usr/lib/vitastor/mon
|
||||||
|
/lib/systemd/system/vitastor-mon.service
|
||||||
|
|
||||||
|
|
||||||
|
%pre -n vitastor-mon
|
||||||
|
groupadd -r -f vitastor 2>/dev/null ||:
|
||||||
|
useradd -r -g vitastor -s /sbin/nologin -c "Vitastor daemons" -M -d /nonexistent vitastor 2>/dev/null ||:
|
||||||
|
|
||||||
|
|
||||||
%files -n vitastor-client
|
%files -n vitastor-client
|
||||||
|
|
|
@ -103,7 +103,7 @@ cd ..
|
||||||
mkdir -p %buildroot/usr/lib/vitastor
|
mkdir -p %buildroot/usr/lib/vitastor
|
||||||
cp -r mon %buildroot/usr/lib/vitastor
|
cp -r mon %buildroot/usr/lib/vitastor
|
||||||
mkdir -p %buildroot/lib/systemd/system
|
mkdir -p %buildroot/lib/systemd/system
|
||||||
cp mon/vitastor-osd@.service %buildroot/lib/systemd/system
|
cp mon/vitastor.target mon/vitastor-mon.service mon/vitastor-osd@.service %buildroot/lib/systemd/system
|
||||||
mkdir -p %buildroot/lib/udev/rules.d
|
mkdir -p %buildroot/lib/udev/rules.d
|
||||||
cp mon/90-vitastor.rules %buildroot/lib/udev/rules.d
|
cp mon/90-vitastor.rules %buildroot/lib/udev/rules.d
|
||||||
|
|
||||||
|
@ -117,11 +117,24 @@ cp mon/90-vitastor.rules %buildroot/lib/udev/rules.d
|
||||||
%_bindir/vitastor-disk
|
%_bindir/vitastor-disk
|
||||||
%_bindir/vitastor-dump-journal
|
%_bindir/vitastor-dump-journal
|
||||||
/lib/systemd/system/vitastor-osd@.service
|
/lib/systemd/system/vitastor-osd@.service
|
||||||
|
/lib/systemd/system/vitastor.target
|
||||||
/lib/udev/rules.d/90-vitastor.rules
|
/lib/udev/rules.d/90-vitastor.rules
|
||||||
|
|
||||||
|
|
||||||
|
%pre -n vitastor-osd
|
||||||
|
groupadd -r -f vitastor 2>/dev/null ||:
|
||||||
|
useradd -r -g vitastor -s /sbin/nologin -c "Vitastor daemons" -M -d /nonexistent vitastor 2>/dev/null ||:
|
||||||
|
install -o vitastor -g vitastor -d /var/log/vitastor
|
||||||
|
|
||||||
|
|
||||||
%files -n vitastor-mon
|
%files -n vitastor-mon
|
||||||
/usr/lib/vitastor/mon
|
/usr/lib/vitastor/mon
|
||||||
|
/lib/systemd/system/vitastor-mon.service
|
||||||
|
|
||||||
|
|
||||||
|
%pre -n vitastor-mon
|
||||||
|
groupadd -r -f vitastor 2>/dev/null ||:
|
||||||
|
useradd -r -g vitastor -s /sbin/nologin -c "Vitastor daemons" -M -d /nonexistent vitastor 2>/dev/null ||:
|
||||||
|
|
||||||
|
|
||||||
%files -n vitastor-client
|
%files -n vitastor-client
|
||||||
|
|
Loading…
Reference in New Issue