File: fix_uid_gid.sh

package info (click to toggle)
python-trame 3.12.0-2
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 101,620 kB
  • sloc: python: 13,515; sh: 183; javascript: 93; makefile: 7
file content (32 lines) | stat: -rwxr-xr-x 689 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/usr/bin/env bash

check_dir=/deploy/server
if [ ! -d $check_dir ]
then
  check_dir=/deploy/setup
fi

deploy_uid=$(stat -c '%u' $check_dir)
deploy_gid=$(stat -c '%g' $check_dir)

trame_user_uid=$(id -u trame-user)
trame_user_gid=$(id -g trame-user)

run_chown=false
if [[ "$deploy_uid" != "$trame_user_uid" ]]; then
  usermod --uid $deploy_uid trame-user
  run_chown=true
fi

if [[ "$deploy_gid" != "$trame_user_gid" ]]; then
  groupmod --gid $deploy_gid trame-user
  run_chown=true
fi

if [[ "$run_chown" == false ]]; then
  exit 0
fi

# Run chown on all trame-user directories/files
chown -R trame-user:trame-user /opt/trame
chown trame-user:proxy-mapping /opt/trame/proxy-mapping.txt