Skip to content

Commit

Permalink
Update package
Browse files Browse the repository at this point in the history
  • Loading branch information
wkobiela committed Nov 25, 2023
1 parent a5d3461 commit d23a127
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 24 deletions.
6 changes: 6 additions & 0 deletions spk/gitea/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,9 @@ SERVICE_PORT_TITLE = $(DISPLAY_NAME) (HTTP)
ADMIN_PORT = $(SERVICE_PORT)

include ../../mk/spksrc.spk.mk

.PHONY: gitea_extra_install
gitea_extra_install:
@$(MSG) "Install config.ini file"
@install -m 755 -d $(STAGING_DIR)/var
@install -m 644 src/config.ini $(STAGING_DIR)/var/config.ini
8 changes: 8 additions & 0 deletions spk/gitea/src/config.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[repository]
ROOT = ${SHARE_PATH}/gitea-repositories
[server]
SSH_DOMAIN = ${IP:=localhost}
DOMAIN = ${IP:=localhost}
ROOT_URL = http://${IP:=localhost}:${SERVICE_PORT}/
[lfs]
PATH = ${SHARE_PATH}/lfs
51 changes: 27 additions & 24 deletions spk/gitea/src/service-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,39 +5,42 @@ PATH="/var/packages/git/target/bin:${PATH}"
if [ $SYNOPKG_DSM_VERSION_MAJOR -lt 7 ]; then
SYNOPKG_PKGHOME="${SYNOPKG_PKGDEST}"
fi

if [ $SYNOPKG_DSM_VERSION_MAJOR -lt 6 ]; then
SYNOPKG_PKGHOME="${SYNOPKG_PKGVAR}"
fi

ENV="PATH=${PATH} HOME=${SYNOPKG_PKGHOME}"

SERVICE_COMMAND="env ${ENV} ${GITEA} web --port ${SERVICE_PORT} --pid ${PID_FILE}"
SVC_BACKGROUND=y

service_preinst ()
service_postinst ()
{
if [ "${SYNOPKG_PKG_STATUS}" == "INSTALL" ] && [ $SYNOPKG_DSM_VERSION_MAJOR -lt 6 ]; then
SHARED_FOLDER="${wizard_shared_folder_name}"
if [ ! -d "${SHARED_FOLDER}" ]; then
mkdir -p "${SHARED_FOLDER}" || {
echo "Failed to create directory \"${SHARED_FOLDER}\"."
exit 1
}
fi
set_syno_permissions "${SHARED_FOLDER}" "${EFF_USER}"
if [ "${SYNOPKG_PKG_STATUS}" == "INSTALL" ]; then
IP=$(ip route get 1 | awk '{print $(NF);exit}')
fi
}

service_postinst ()
service_preupgrade ()
{
if [ "${SYNOPKG_PKG_STATUS}" == "INSTALL" ]; then
SHARED_FOLDER="${wizard_shared_folder_name}"
IP=$(ip route get 1 | awk '{print $(NF);exit}')
# Default configuration with shared folder
{
echo "[repository]"
echo "ROOT = ${SHARED_FOLDER}/gitea-repositories"
echo "[server]"
echo "LFS_CONTENT_PATH = ${SHARED_FOLDER}/lfs"
echo "SSH_DOMAIN = ${IP:=localhost}"
echo "DOMAIN = ${IP:=localhost}"
echo "ROOT_URL = http://${IP:=localhost}:${SERVICE_PORT}/"
} > "$CONF_FILE"
#Backup existing config on DSM6
if [ ${SYNOPKG_DSM_VERSION_MAJOR} -lt 6 ]; then
if [-f "${SYNOPKG_PKGHOME}/conf.ini" ]; then
echo "Backup old config on DSM6"
mv ${SYNOPKG_PKGHOME}/conf.ini ${SYNOPKG_PKGHOME}/conf.ini.bck 2>&1
fi
fi
}

service_postupgrade ()
{
#Restore existing config on DSM6
if [ ${SYNOPKG_DSM_VERSION_MAJOR} -lt 6 ]; then
if [-f "${SYNOPKG_PKGHOME}/conf.ini.bkc" ]; then
echo "Restore old config on DSM6"
rm -f ${SYNOPKG_PKGHOME}/conf.ini
mv ${SYNOPKG_PKGHOME}/conf.ini.bck ${SYNOPKG_PKGHOME}/conf.ini 2>&1
fi
fi
}
8 changes: 8 additions & 0 deletions spk/gitea/src/wizard/upgrade_uifile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[{
"step_title": "Updating Gitea",
"items": [{
"desc": "Please, be aware that configuration file may require some manual adjustments."
},{
"desc": "Check Gitea admin panel after upgrade and adjust gitea/var/conf.ini as needed."
}]
}]

0 comments on commit d23a127

Please sign in to comment.