2018-10-30 14:50:33 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
# Install and initialize gitea
|
|
|
|
|
|
|
|
|
|
|
|
# Variables
|
|
|
|
|
|
|
|
WKDIR="/srv/forge"
|
|
|
|
|
|
|
|
USER="git"
|
|
|
|
GROUP="gitservice"
|
|
|
|
GECOS="Gitea User"
|
|
|
|
USERSHELL="/bin/bash"
|
|
|
|
HOMEDIR="${WKDIR}/${USER}"
|
|
|
|
|
|
|
|
OS="linux"
|
|
|
|
ARCH="amd64"
|
|
|
|
|
2019-06-17 14:22:47 +02:00
|
|
|
APPVERSION="1.8.2"
|
2018-10-30 14:50:33 +01:00
|
|
|
APPNAME="gitea"
|
|
|
|
APPBINARY="gitea"
|
|
|
|
APPSIG="7C9E68152594688862D62AF62D9AE806EC1592E2"
|
|
|
|
APPASC="${APPNAME}-${APPVERSION}-${OS}-${ARCH}.asc"
|
|
|
|
KEYSERV="pgp.mit.edu"
|
|
|
|
DLSERV="dl.gitea.io"
|
|
|
|
APPDIR="${WKDIR}/gitea"
|
|
|
|
APPBINDIR="${APPDIR}/bin"
|
|
|
|
APPCONFDIR="/etc/${APPNAME}"
|
|
|
|
|
|
|
|
if [[ -d ${APPCONFDIR} ]]
|
|
|
|
then
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
proxy=$(CreoleGet activer_proxy_client non)
|
|
|
|
|
|
|
|
if [[ ${proxy} == "oui" ]]
|
|
|
|
then
|
|
|
|
prAddr=$(CreoleGet proxy_client_adresse)
|
|
|
|
prPort=$(CreoleGet proxy_client_port)
|
|
|
|
export HTTP_PROXY=http://${prAddr}:${prPort}
|
|
|
|
export http_proxy=http://${prAddr}:${prPort}
|
|
|
|
export HTTPS_PROXY=http://${prAddr}:${prPort}
|
|
|
|
export https_proxy=http://${prAddr}:${prPort}
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ ! -d ${APPDIR} ]]
|
|
|
|
then
|
|
|
|
mkdir -p ${APPDIR}
|
2018-10-30 15:22:45 +01:00
|
|
|
chown ${USER}:${GROUP} ${APPDIR} -R
|
2018-10-30 14:50:33 +01:00
|
|
|
fi
|
|
|
|
|
|
|
|
# Create app user and group
|
|
|
|
groupadd ${GROUP}
|
|
|
|
adduser \
|
|
|
|
--shell ${USERSHELL} \
|
|
|
|
--gecos "${GECOS}" \
|
|
|
|
--ingroup ${GROUP} \
|
|
|
|
--disabled-password \
|
|
|
|
--home ${HOMEDIR} \
|
|
|
|
${USER}
|
|
|
|
|
|
|
|
# Create app structure
|
|
|
|
mkdir -p ${APPDIR}/{custom,data,indexers,public,log}
|
|
|
|
chown ${USER}:${GROUP} ${APPDIR}/{data,indexers,log}
|
|
|
|
chmod 750 ${APPDIR}/{data,indexers,log}
|
|
|
|
mkdir ${APPCONFDIR}
|
|
|
|
chown root:${GROUP} ${APPCONFDIR}
|
|
|
|
chmod 770 ${APPCONFDIR}
|
|
|
|
|
|
|
|
if [[ ! -d ${APPBINDIR} ]]
|
|
|
|
then
|
|
|
|
mkdir -p ${APPBINDIR}
|
2018-10-30 15:22:45 +01:00
|
|
|
chown ${USER}:${GROUP} ${APPBINDIR}
|
2018-10-30 14:50:33 +01:00
|
|
|
fi
|
|
|
|
|
|
|
|
cd $APPBINDIR
|
|
|
|
if [[ ! -f ${APPBINARY} ]]
|
|
|
|
then
|
|
|
|
wget -O ${APPBINARY} https://${DLSERV}/${APPNAME}/${APPVERSION}/${APPNAME}-${APPVERSION}-${OS}-${ARCH}
|
|
|
|
if [[ $? -eq 0 ]]
|
|
|
|
then
|
|
|
|
chmod +x ${APPBINARY}
|
|
|
|
else
|
|
|
|
echo "Error downloading binary for ${APPNAME}"
|
|
|
|
return 123
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ ! -f ${APPASC} ]]
|
|
|
|
then
|
|
|
|
wget -O ${APPASC} https://${DLSERV}/${APPNAME}/${APPVERSION}/${APPASC}
|
|
|
|
gpg --keyserver ${KEYSERV} --recv ${APPSIG}
|
|
|
|
gpg --verify ${APPNAME}-${APPVERSION}-${OS}-${ARCH}.asc ${APPBINARY}
|
|
|
|
fi
|
|
|
|
cd -
|