1#!/bin/sh 2 3# copy_postgresql_config_files.sh 4# PostgreSQL 5 6# Copyright (c) 2012 Apple Inc. All Rights Reserved. 7# 8# IMPORTANT NOTE: This file is licensed only for use on Apple-branded 9# computers and is subject to the terms and conditions of the Apple Software 10# License Agreement accompanying the package this file is a part of. 11# You may not port this file to another platform without Apple's written consent. 12 13# 14# Copies the default PostgreSQL config file into /Library/Server during promotion or migration 15# This file handles the copying for both server and customer instances of postgres. Argument 1 16# should be passed in as either "server" or "customer" to specify which files to copy. 17# 18 19INSTANCE="$1" 20ServerRoot="/Applications/Server.app/Contents/ServerRoot" 21SourceConfig="" 22DestConfig="" 23ConfigDir="" 24if [ "$INSTANCE" == "server" ]; then 25 SourceConfig="$ServerRoot/Library/Preferences/com.apple.postgres.plist" 26 ConfigDir="/Library/Server/PostgreSQL For Server Services/Config" 27 DestConfig="$ConfigDir/com.apple.postgres.plist" 28elif [ "$INSTANCE" == "customer" ]; then 29 SourceConfig="$ServerRoot/Library/Preferences/org.postgresql.postgres.plist" 30 ConfigDir="/Library/Server/PostgreSQL/Config" 31 DestConfig="$ConfigDir/org.postgresql.postgres.plist" 32else 33 echo "No valid argument passed in; argument 1 should be either \"customer\" or \"server\"" 34 exit 1 35fi 36 37echo "Creating directory $ConfigDir..." 38/bin/mkdir -p "$ConfigDir" 39if [ $? != 0 ]; then 40 echo "Error creating directory, exiting" 41 exit 1; 42fi 43/usr/sbin/chown _postgres:_postgres "$ConfigDir" 44/bin/chmod 0755 "$ConfigDir" 45 46echo "Copying PostgreSQL $INSTANCE configuration files into /Libary/Server..." 47/usr/bin/ditto "$SourceConfig" "$DestConfig" 48/usr/sbin/chown _postgres:_postgres "$DestConfig" 49/bin/chmod 644 "$DestConfig" 50echo "Finished." 51