Commit 831f7b4a authored by Marcus's avatar Marcus

install script

parent be8243d5
#!/bin/bash
SERVICE="feudalClient"
LIB_SYSD="/lib/systemd/system"
SYSD_SERVICE=feudalClient.service
USER="feudal"
ETC_CONFIG=/etc/feudal
ADAPTER_BRANCH=remove-marcus-legacy
GOPATH=/tmp/go
INSTALLDIR=/tmp/feudalClientInstaller
pushd ./ > /dev/null
test -e ${INSTALLDIR} || mkdir -p ${INSTALLDIR}
### find pip
PIP=`which pip3`
test -z $PIP && {
PIP=`which pip`
test -z $PIP && {
echo -e "pip not found.\n => apt-get install python3-pip"
exit 1
}
}
### Add feudal user
echo "Adding user ${USER}"
useradd -m ${USER} > /dev/null 2>&1
RV=$?
case "$RV" in
0-8) echo "Error creating user"; exit 1;;
10-14) echo "Error creating user"; exit 1;;
esac
### Install feudalClient
test -e ${INSTALLDIR}/feudalClient/feudalClient && {
echo -e "feudalClient seems to be installed already, skipping"
}
test -e ${INSTALLDIR}/feudalClient/feudalClient || {
echo -e "\nbuilding feudalClient"
cd ${INSTALLDIR}
git clone https://git.scc.kit.edu/feudal/feudalClient.git > /dev/null 2>&1
cd feudalClient
go get
go build
echo -e "Installing feudalClient"
USER_HOME=`eval echo "~${USER}"`
install -m 755 -o ${USER} -d ${USER_HOME}/bin/
install -m 755 -o ${USER} feudalClient ${USER_HOME}/bin/feudalClient
echo -e "feudalClient installed"
}
### Install feudalAdapterLDF
echo -e "\nInstalling feudalAdapterLDF"
cd ${INSTALLDIR}
test -d feudalAdapterLDF || {
git clone https://git.scc.kit.edu/feudal/feudalAdapterLDF > /dev/null 2>&1
}
cd feudalAdapterLDF
git co ${ADAPTER_BRANCH} > /dev/null 2>&1
git pull > /dev/null 2>&1
./setup.py sdist > /dev/null
FULLNAME=`python3 setup.py --fullname`
pip install dist/$FULLNAME.tar.gz > /dev/null
echo -e "feudalAdapterLDF installed"
# => ldf_adapter is now in $PATH
### Prepare config
cd ${INSTALLDIR}
test -d ${ETC_CONFIG} || {
echo "Creating template ${ETC_CONFIG} and copying defaults there"
mkdir -p ${ETC_CONFIG}
chown -R ${USER} ${ETC_CONFIG}
echo "You will have to edit the template files in the config"
}
### Install Config Files
test -e ${ETC_CONFIG}/ldf_adapter.conf || {
echo "Installing a template for ldf_adapter.conf in ${ETC_CONFIG}"
echo " => You need to edit this file"
cp feudalAdapterLDF/ldf_adapter_template.conf ${ETC_CONFIG}
}
popd > /dev/null
test -e ${ETC_CONFIG}/client_config.json || {
echo "Installing a template for client_config_template.json in ${ETC_CONFIG}"
echo " => You need to edit this file"
cp client_config_template.json ${ETC_CONFIG}
}
test -e ${ETC_CONFIG}/environment || {
echo "Installing a template for environment in ${ETC_CONFIG}"
cp environment ${ETC_CONFIG}
}
# Ensure config permissions
chown -R ${USER} ${ETC_CONFIG}
### Install systemd Service
echo -e "\nInstalling / updating systemd service for ${SYSD_SERVICE}"
test -e ${LIB_SYSD}/${SERVICE}.service && {
diff -q ${SYSD_SERVICE} ${LIB_SYSD} >/dev/null || {
echo "Preparing systemd service for update"
rm -f ${LIB_SYSD}/${SERVICE}.service
}
}
test -e ${LIB_SYSD}/${SERVICE}.service || {
cp ${SYSD_SERVICE} ${LIB_SYSD}/${SERVICE}.service
systemctl daemon-reload
}
echo -e "Done\nRestarting ${SYSD_SERVICE}"
systemctl enable $SERVICE
systemctl restart $SERVICE
echo "Done"
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment