2024-02-19 21:15:03 -05:00
|
|
|
#!/bin/bash
|
2024-09-16 00:49:57 -04:00
|
|
|
# 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.
|
2024-02-19 21:15:03 -05:00
|
|
|
|
2024-09-16 00:49:57 -04:00
|
|
|
. ./config
|
2024-02-19 21:15:03 -05:00
|
|
|
|
2024-09-16 00:49:57 -04:00
|
|
|
# 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}" ]] && {
|
2024-02-19 21:15:03 -05:00
|
|
|
echo "You haven't built nginx-cn yet. Do so with ./build"
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
2024-09-16 00:49:57 -04:00
|
|
|
# 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/
|
|
|
|
}
|
2024-02-19 21:15:03 -05:00
|
|
|
|
2024-09-16 00:49:57 -04:00
|
|
|
echo "nginx-cn has been installed/updated."
|