mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-21 17:10:12 +01:00
parent
56ee07f703
commit
4ef5d90af3
1 changed files with 18 additions and 6 deletions
|
|
@ -6,6 +6,7 @@ PUID=${PUID:-1000}
|
||||||
PGID=${PGID:-1000}
|
PGID=${PGID:-1000}
|
||||||
USER_NAME=${USER_NAME:-siyuan}
|
USER_NAME=${USER_NAME:-siyuan}
|
||||||
GROUP_NAME=${GROUP_NAME:-siyuan}
|
GROUP_NAME=${GROUP_NAME:-siyuan}
|
||||||
|
WORKSPACE_DIR="/siyuan/workspace"
|
||||||
|
|
||||||
# Get or create group
|
# Get or create group
|
||||||
group_name="${GROUP_NAME}"
|
group_name="${GROUP_NAME}"
|
||||||
|
|
@ -19,7 +20,7 @@ fi
|
||||||
|
|
||||||
# Get or create user
|
# Get or create user
|
||||||
user_name="${USER_NAME}"
|
user_name="${USER_NAME}"
|
||||||
if id -u "${PUID}" > /dev/null 2>&1; then
|
if getent passwd "${PUID}" > /dev/null 2>&1; then
|
||||||
user_name=$(getent passwd "${PUID}" | cut -d: -f1)
|
user_name=$(getent passwd "${PUID}" | cut -d: -f1)
|
||||||
echo "Using existing user ${user_name} (PUID: ${PUID}, PGID: ${PGID})"
|
echo "Using existing user ${user_name} (PUID: ${PUID}, PGID: ${PGID})"
|
||||||
else
|
else
|
||||||
|
|
@ -27,11 +28,22 @@ else
|
||||||
adduser --uid "${PUID}" --ingroup "${group_name}" --disabled-password --gecos "" "${user_name}"
|
adduser --uid "${PUID}" --ingroup "${group_name}" --disabled-password --gecos "" "${user_name}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Change ownership of relevant directories
|
# Parse command line arguments for --workspace option
|
||||||
echo "Adjusting ownership of /opt/siyuan and /home/siyuan/"
|
# Store other arguments in ARGS for later use
|
||||||
|
ARGS=""
|
||||||
|
while [[ "$#" -gt 0 ]]; do
|
||||||
|
case $1 in
|
||||||
|
--workspace=*) WORKSPACE_DIR="${1#*=}"; shift ;;
|
||||||
|
*) ARGS="$ARGS $1"; shift ;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
# Change ownership of relevant directories, including the workspace directory
|
||||||
|
echo "Adjusting ownership of /opt/siyuan, /home/siyuan/, and ${WORKSPACE_DIR}"
|
||||||
chown -R "${PUID}:${PGID}" /opt/siyuan
|
chown -R "${PUID}:${PGID}" /opt/siyuan
|
||||||
chown -R "${PUID}:${PGID}" /home/siyuan/
|
chown -R "${PUID}:${PGID}" /home/siyuan/
|
||||||
|
chown -R "${PUID}:${PGID}" "${WORKSPACE_DIR}"
|
||||||
|
|
||||||
# Switch to the newly created user and start the main process
|
# Switch to the newly created user and start the main process with all arguments
|
||||||
echo "Starting Siyuan with UID:${PUID} and GID:${PGID}"
|
echo "Starting Siyuan with UID:${PUID} and GID:${PGID} in workspace ${WORKSPACE_DIR}"
|
||||||
exec su-exec "${PUID}:${PGID}" /opt/siyuan/kernel "$@"
|
exec su-exec "${PUID}:${PGID}" /opt/siyuan/kernel --workspace="${WORKSPACE_DIR}" ${ARGS}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue