diff --git a/tdbms/install.sh b/tdbms/install.sh index 9f067ea..16b854f 100644 --- a/tdbms/install.sh +++ b/tdbms/install.sh @@ -1,13 +1,13 @@ #!/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 echo "Please run as root" exit 1 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 id tanabata &>/dev/null || useradd -u 42776 -g 42776 tanabata @@ -56,19 +56,25 @@ fi chown 42776:42776 /var/log/tanabata chmod 2755 /var/log/tanabata -if [ ! -d "$SCRIPT_DIR/../build" ]; then - mkdir "$SCRIPT_DIR/../build" +if [ -d ../build ]; then + rm -r ../build/* +else + mkdir ../build + if [ -d ../build ]; then + echo "FATAL: failed to create build directory" + exit 1 + 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" exit 1 fi -mv -f "$SCRIPT_DIR/../build/tdbms" /usr/bin/ +mv -f ../build/tdbms /usr/bin/ chown 0:0 /usr/bin/tdbms chmod 0755 /usr/bin/tdbms -if ! cp "$SCRIPT_DIR/tdbms.service" /etc/systemd/system/; then - echo "FATAL: sailed to copy 'tdbms.service' to '/etc/systemd/system'" +if ! cp ./tdbms.service /etc/systemd/system/; then + echo "FATAL: failed to copy 'tdbms.service' to '/etc/systemd/system'" fi chown 0:0 /etc/systemd/system/tdbms.service chmod 0644 /etc/systemd/system/tdbms.service