1#!/usr/bin/env sh 2 3# 4# Arm SCP/MCP Software 5# Copyright (c) 2021-2023, Arm Limited and Contributors. All rights reserved. 6# 7# SPDX-License-Identifier: BSD-3-Clause 8# 9 10if id vagrant > /dev/null 2>&1; then 11 user=vagrant 12elif id user > /dev/null 2>&1; then 13 user=user 14fi 15 16if [ -z "${user}" ]; then 17 exec $@ 18else 19 uid=$(stat -c "%u" ".") 20 gid=$(stat -c "%u" ".") 21 22 usermod -u ${uid} ${user} 23 groupmod -g ${gid} ${user} 24 25 if [ $# -eq 0 ]; then 26 exec su ${user} 27 else 28 exec gosu ${user} $@ 29 fi 30fi 31