perf(dbms): improve TDBMS installer script

This commit is contained in:
Masahiko AMANO 2023-01-30 18:30:08 +03:00
parent d72348e639
commit e9c0c6340a

View File

@ -1,13 +1,13 @@
#!/bin/bash #!/bin/bash
# This script performs the installation of the TDBMS server # This script performs the installation of the Tanabata DBMS server
if [ "$EUID" -ne 0 ]; then if [ "$EUID" -ne 0 ]; then
echo "Please run as root" echo "Please run as root"
exit 1 exit 1
fi fi
SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd) cd "$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd)"
getent group tanabata &>/dev/null || groupadd -g 42776 tanabata getent group tanabata &>/dev/null || groupadd -g 42776 tanabata
id tanabata &>/dev/null || useradd -u 42776 -g 42776 tanabata id tanabata &>/dev/null || useradd -u 42776 -g 42776 tanabata
@ -56,19 +56,25 @@ fi
chown 42776:42776 /var/log/tanabata chown 42776:42776 /var/log/tanabata
chmod 2755 /var/log/tanabata chmod 2755 /var/log/tanabata
if [ ! -d "$SCRIPT_DIR/../build" ]; then if [ -d ../build ]; then
mkdir "$SCRIPT_DIR/../build" rm -r ../build/*
else
mkdir ../build
if [ -d ../build ]; then
echo "FATAL: failed to create build directory"
exit 1
fi
fi fi
if ! (cmake -S "$SCRIPT_DIR/.." -B "$SCRIPT_DIR/../build" && cmake --build "$SCRIPT_DIR/../build" --target tdbms); then if ! (cmake -S .. -B ../build && cmake --build ../build --target tdbms); then
echo "FATAL: failed to build TDBMS server" echo "FATAL: failed to build TDBMS server"
exit 1 exit 1
fi fi
mv -f "$SCRIPT_DIR/../build/tdbms" /usr/bin/ mv -f ../build/tdbms /usr/bin/
chown 0:0 /usr/bin/tdbms chown 0:0 /usr/bin/tdbms
chmod 0755 /usr/bin/tdbms chmod 0755 /usr/bin/tdbms
if ! cp "$SCRIPT_DIR/tdbms.service" /etc/systemd/system/; then if ! cp ./tdbms.service /etc/systemd/system/; then
echo "FATAL: sailed to copy 'tdbms.service' to '/etc/systemd/system'" echo "FATAL: failed to copy 'tdbms.service' to '/etc/systemd/system'"
fi fi
chown 0:0 /etc/systemd/system/tdbms.service chown 0:0 /etc/systemd/system/tdbms.service
chmod 0644 /etc/systemd/system/tdbms.service chmod 0644 /etc/systemd/system/tdbms.service