nginx-cn/install
modeco80 1be51ac906 Completely revamp installation script
Instead of cluttering the $PREFIX during build (and requiring root to do so),
we now install everything into a temporary directrory that is copied in piecemeal
to the prefix). Additionally, the installer will now, on a fresh installation only,
copy the base config files from /conf to $PREFIX/etc/nginx. A existing installation
will not have this performed (unlike the upstream nginx installation rules), so your
configuration will be safe.
2024-09-16 00:51:47 -04:00

40 lines
1.3 KiB
Bash
Executable file

#!/bin/bash
# Installs nginx-cn into the configured PREFIX.
#
# N.B: We do not use nginx's `make install` because it's very very bad
# and it overwrites $PREFIX/etc unconditionally. It's bad design choice,
# and I personally do not like it.
. ./config
# Check for the install prefix directory. If it doesn't exist,
# then a build likely hasn't been done, so we can't proceed.
[[ ! -d "${INSTALL_PREFIX}" ]] && {
echo "You haven't built nginx-cn yet. Do so with ./build"
exit 1
}
# We're replacing an existing installation.
# Make sure not to overwrite a user's existing configuration
[[ -d "${PREFIX}/etc/nginx" ]] && {
echo "You seem to have a configuration in your PREFIX."
echo "I will not touch it."
# Remove old files and replace them with the install prefix versions
rm -rf ${PREFIX}/{bin,lib,share}
cp -r ${INSTALL_PREFIX}/bin ${PREFIX}/bin
cp -r ${INSTALL_PREFIX}/lib ${PREFIX}/lib
cp -r ${INSTALL_PREFIX}/share ${PREFIX}/share
}
# A new installation.
# We SHOULD copy over the configuration now.
[[ ! -d "${PREFIX}" ]] && {
mkdir -p ${PREFIX} ${PREFIX}/etc/nginx
cp -r ${INSTALL_PREFIX}/bin ${PREFIX}/bin
cp -r ${INSTALL_PREFIX}/lib ${PREFIX}/lib
cp -r ${INSTALL_PREFIX}/share ${PREFIX}/share
cp -r ${TOP}/conf ${PREFIX}/etc/nginx/
}
echo "nginx-cn has been installed/updated."