From 64f414aa0172d992ca2c4c46c4c5cc8564fe0c5a Mon Sep 17 00:00:00 2001 From: Sanjeev Rohila Date: Fri, 18 Apr 2025 16:34:44 +0530 Subject: [PATCH] test changes duplicate with execStart PR URL: https://www.github.com/delphix/delphix-platform/pull/525 --- debian/preinst | 42 +++++++++++++++++++ .../systemd/system/delphix-platform.service | 17 ++++++++ .../roles/delphix-platform/tasks/main.yml | 8 ++-- 3 files changed, 63 insertions(+), 4 deletions(-) create mode 100644 debian/preinst diff --git a/debian/preinst b/debian/preinst new file mode 100644 index 000000000..a22ccb233 --- /dev/null +++ b/debian/preinst @@ -0,0 +1,42 @@ +#!/bin/bash -eux +# +# Copyright 2025 Delphix +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +case $1 in +upgrade) + # Home directories were previously mounted under /export/home, + # and this was changed to /home. This is the upgrade logic that + # updates the /etc/fstab file to reflect that change. + # Home directories will be mounted in both /export/home and /home + # until the system is rebooted to ensure that running processes + # referencing the old /export/home paths continue to function + # while also enabling new logins under /home to work. + fs_tab=/etc/fstab + + if grep -q "\/export\/home" "$fs_tab"; then + sed -i 's|/export/home|/home|g' "$fs_tab" + mount /home + fi + + passwd_file=/etc/passwd + if grep -q "\/export\/home" "$passwd_file"; then + sed -i 's/\/export\/home/\/home/g' /etc/passwd + fi + + ;; +esac + +exit 0 diff --git a/files/common/lib/systemd/system/delphix-platform.service b/files/common/lib/systemd/system/delphix-platform.service index 89a809d67..388b74a20 100644 --- a/files/common/lib/systemd/system/delphix-platform.service +++ b/files/common/lib/systemd/system/delphix-platform.service @@ -24,6 +24,23 @@ Before=rsync.service docker.service Type=oneshot ExecStart=/var/lib/delphix-platform/ansible/apply ExecStart=/var/lib/delphix-platform/dynamic-debug +ExecStart=/bin/sh -c '\ + echo "Ensuring /export/home is a symlink to /home..."; \ + if mountpoint -q /export/home; then \ + echo "/export/home is a mountpoint, unmounting..."; \ + umount /export/home || { echo "Failed to unmount /export/home"; exit 1; }; \ + fi; \ + if [ -e /export/home ] && [ ! -L /export/home ]; then \ + echo "Removing existing /export/home directory..."; \ + rm -rf /export/home; \ + fi; \ + if [ ! -d /export ]; then \ + mkdir /export; \ + fi; \ + if [ -d /export ] && [ ! -L /export/home ]; then \ + echo "Creating symlink: /export/home -> /home"; \ + ln -s /home /export/home; \ + fi;' RemainAfterExit=yes # diff --git a/files/common/var/lib/delphix-platform/ansible/10-delphix-platform/roles/delphix-platform/tasks/main.yml b/files/common/var/lib/delphix-platform/ansible/10-delphix-platform/roles/delphix-platform/tasks/main.yml index 36f1956af..c87ff2bbf 100644 --- a/files/common/var/lib/delphix-platform/ansible/10-delphix-platform/roles/delphix-platform/tasks/main.yml +++ b/files/common/var/lib/delphix-platform/ansible/10-delphix-platform/roles/delphix-platform/tasks/main.yml @@ -1,5 +1,5 @@ # -# Copyright 2018, 2023 Delphix +# Copyright 2018, 2025 Delphix # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -22,7 +22,7 @@ # it below; otherwise that task will fail. # - file: - path: /export/home + path: /home state: directory mode: 0755 @@ -35,7 +35,7 @@ shell: /bin/bash create_home: yes comment: Delphix User - home: /export/home/delphix + home: /home/delphix # # In order for this locale to be used (e.g. by virtualization) we need @@ -689,7 +689,7 @@ - name: Source bash completion blockinfile: - dest: "/export/home/delphix/.bashrc" + dest: "/home/delphix/.bashrc" block: | . /etc/bash_completion.d/systemctl . /etc/bash_completion.d/zfs