#!/bin/bash

source debian/vars.sh

# logrotate
mkdir -p $buildroot/var/log/ea-passenger-analytics
mkdir -p $buildroot$_sysconfdir/logrotate.d/
install -m 644 $SOURCE0 $buildroot$_sysconfdir/logrotate.d/ea-passenger
# tmp files
mkdir -p $buildroot/var/run/ea-passenger-runtime
mkdir -p $buildroot/usr/lib/tmpfiles.d
install -m 644 $SOURCE1 $buildroot/usr/lib/tmpfiles.d/ea-passenger.conf
# sane defaults
# NOTE: these defaults may not actually get set, the build environment may not
# have these present so they may not make it into the rpm or deb.
# pkg.postinst has a fallback system-default creation.
mkdir -p $buildroot/etc/cpanel/ea4
# Need to create the symlinks so that the RPM can own them
#   Create them with a value that %posttrans will fix (and that won’t get reset due to %config(noreplace))
ln -s /usr/local/bin/ea-passenger-runtime_ruby-is-not-installed   $buildroot/etc/cpanel/ea4/passenger.ruby.system-default
ln -s /usr/local/bin/ea-passenger-runtime_python-is-not-installed $buildroot/etc/cpanel/ea4/passenger.python.system-default
ln -s /usr/local/bin/ea-passenger-runtime_nodejs-is-not-installed $buildroot/etc/cpanel/ea4/passenger.nodejs.system-default
# user passenger app config check/fix script used in %posttrans
mkdir -p $buildroot/usr/local/bin
install -m 755 $SOURCE3 $buildroot/usr/local/bin/ea-passenger-runtime-applications-settings
install -m 755 $SOURCE4 $buildroot/usr/local/bin/ea-passenger-runtime_ruby-is-not-installed
ln -s /usr/local/bin/ea-passenger-runtime_ruby-is-not-installed $buildroot/usr/local/bin/ea-passenger-runtime_python-is-not-installed
ln -s /usr/local/bin/ea-passenger-runtime_ruby-is-not-installed $buildroot/usr/local/bin/ea-passenger-runtime_nodejs-is-not-installed
