blob: bf55da05c74dc5d06f16191bc15ed2c1c35a6966 [file] [log] [blame]
Jack Lucas8ad4f6d2018-12-04 15:02:06 -05001#!/bin/bash
2# ================================================================================
3# Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.
4# ================================================================================
5# Licensed under the Apache License, Version 2.0 (the "License");
6# you may not use this file except in compliance with the License.
7# You may obtain a copy of the License at
8#
9# http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS,
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
16# ============LICENSE_END=========================================================
17# Set up persistent storage for Cloudify Manager's state data
18
19PDIRS="/var/lib/pgsql/9.5/data /opt/manager/resources /opt/mgmtworker/env/plugins /opt/mgmtworker/work/deployments"
20PSTORE="/cfy-persist"
21
22set -ex
23
24if [ -d "$PSTORE" ]
25then
26 # the persistent mount point exists
27 if [ -z "$(ls -A $PSTORE)" ]
28 then
29 # there's nothing in the persistent store yet
30 # copy in the data from the container file system
31 for d in $PDIRS
32 do
33 p="$(dirname $d)"
34 mkdir -p "${PSTORE}$p"
35 cp -rp "$d" "${PSTORE}$p"
36 done
37 fi
38 # at this point, there is persistent storage possibly from a previous startup
39 # set up links from internal file system to persistent storage
40 for d in $PDIRS
41 do
42 if [ -d "$d" ]
43 then
44 mv $d $d-initial # move directory so we can create symlink
45 fi
46 ln -sf "$PSTORE/$d" "$(dirname $d)"
47 done
48else
49 echo "No persistent storage available"
50fi
51# start up init, which brings up CM and supporting software
52exec /sbin/init --log-target=journal 3>&1
53