2016-07-03 21:50:55 +02:00
|
|
|
#!/bin/bash
|
|
|
|
set -e
|
2017-04-27 22:58:43 +02:00
|
|
|
set -o pipefail
|
|
|
|
|
2017-06-09 20:00:18 +02:00
|
|
|
COMMAND=/opt/sublime_text/sublime_text
|
|
|
|
|
2016-07-03 21:50:55 +02:00
|
|
|
if [ -z ${NEWUSER+x} ]; then
|
2018-09-25 00:46:13 +02:00
|
|
|
echo "WARN: No user was defined, defaulting to root."
|
|
|
|
echo "WARN: Sublime will save files as root:root."
|
|
|
|
echo " To prevent this, start the container with -e NEWUSER=\$USER"
|
|
|
|
exec "$COMMAND" -w
|
2016-07-03 21:50:55 +02:00
|
|
|
else
|
|
|
|
# The root user already exists, so we only need to do something if
|
|
|
|
# a user has been specified.
|
2018-09-25 00:46:13 +02:00
|
|
|
useradd -s /bin/bash "$NEWUSER"
|
2016-07-03 21:50:55 +02:00
|
|
|
# If you'd like to have Sublime Text add your development folder
|
|
|
|
# to the current project (i.e. in the sidebar at start), append
|
|
|
|
# "-a /home/$NEWUSER/Documents" (without quotes) into the su -c command below.
|
2017-06-09 20:00:18 +02:00
|
|
|
# Example: su $NEWUSER -c "$COMMAND -w -a /home/$NEWUSER/Documents"
|
2018-09-25 00:46:13 +02:00
|
|
|
su "$NEWUSER" -c "$COMMAND -w"
|
2016-07-03 21:50:55 +02:00
|
|
|
fi
|