glacier-old/install/build.sh

73 lines
2.2 KiB
Bash
Executable File

#!/bin/sh
if [[ $(/usr/bin/id -u) -ne 0 ]]; then
printf "must be run as root\n"
exit 1
fi
WORKING_DIR=$(pwd)
SRC_DIR=$(pwd)/../src
printf "parsing install.conf\n"
source $WORKING_DIR/install.conf
if [ "$?" != 0 ]; then
printf "install.conf not found\n"
exit 1
fi
case $1 in
install)
printf "installing executable\n"
mv -v $SRC_DIR/glacier $PREFIX/bin
if [ "$?" != 0 ]; then
mv -v $SRC_DIR/glacier $PREFIX
printf "directory $PREFIX/bin does not exist, moving to $PREFIX instead\n"
fi
$CC $SRC_DIR/int-check/main.c -o glacier-integrity-check
mv -v $SRC_DIR/int-check/glacier-integrity-check $PREFIX/bin
if [ "$?" != 0 ]; then
mv -v $SRC_DIR/int-check/glacier-integrity-check $PREFIX
printf "directory $PREFIX/bin does not exist, moving to $PREFIX instead.\n"
fi
printf "installing configuration files\n"
mv -v $SRC_DIR/glacier.conf $CONFDIR
if [ "$?" != 0 ]; then
printf "$CONFDIR does not exist\n"
printf "this can be corrected by running:\n"
printf "# mkdir -v -pv $CONFDIR\n"
exit 1
fi
mkdir -v /opt/glacier
mkdir -v /opt/glacier/workspace
mkdir -v /var/log/glacier
mkdir -v /var/cache/glacier
mkdir -v /etc/glacier
mkdir -v /etc/glacier/pkginfo
mv -v $SRC_DIR/hooks $CONFDIR/glacier
mv -v $SRC_DIR/post-hooks $CONFDIR/glacier
mv -v $SRC_DIR/pre-hooks $CONFDIR/glacier
mv -v $SRC_DIR/hooks.sh $CONFDIR/glacier
mv -v $SRC_DIR/make.conf $CONFDIR
mv -v $SRC_DIR/glacier-integrity-check $PREFIX/bin
if [ "$?" != "0" ]; then
mv -v $SRC_DIR/glacier-integrity-check $PREFIX
printf "directory $PREFIX/bin does not exist, moving to $PREFIX instead\n"
fi
printf "finished installation\n"
exit 0
;;
update)
printf "updating executable\n"
rm -v $PREFIX/bin/glacier || rm -v $PREFIX/glacier
rm -v $PREFIX/bin/glacier-integrity-check || rm -v $PREFIX/glacier-integrity-check
mv -v $SRC_DIR/glacier $PREFIX/bin || mv -v $SRC_DIR/glacier $PREFIX
$CC $SRC_DIR/int-check/main.c -O2 -fstack-protector-strong -o $SRC_DIR/int-check/glacier-integrity-check
mv -v $SRC_DIR/int-check/glacier-integrity-check $PREFIX/bin || mv -v $SRC_DIR/int-check/glacier-integrity-check $PREFIX
printf "finished updating\n"
exit 0
esac