optional sudo password via env variable

This commit is contained in:
aptalca 2019-07-09 17:29:50 -04:00
parent 886c4797f9
commit b722cd6c8f
4 changed files with 20 additions and 4 deletions

View File

@ -15,7 +15,8 @@ RUN \
apt-get install -y \ apt-get install -y \
git \ git \
nano \ nano \
net-tools && \ net-tools \
sudo && \
echo "**** install code-server ****" && \ echo "**** install code-server ****" && \
if [ -z ${CODE_RELEASE+x} ]; then \ if [ -z ${CODE_RELEASE+x} ]; then \
CODE_RELEASE=$(curl -sX GET "https://api.github.com/repos/cdr/code-server/releases/latest" \ CODE_RELEASE=$(curl -sX GET "https://api.github.com/repos/cdr/code-server/releases/latest" \

View File

@ -58,6 +58,7 @@ docker create \
-e PGID=1000 \ -e PGID=1000 \
-e TZ=Europe/London \ -e TZ=Europe/London \
-e PASSWORD=password `#optional` \ -e PASSWORD=password `#optional` \
-e SUDO_PASSWORD=password `#optional` \
-p 8443:8443 \ -p 8443:8443 \
-v /path/to/appdata/config:/config \ -v /path/to/appdata/config:/config \
--restart unless-stopped \ --restart unless-stopped \
@ -81,6 +82,7 @@ services:
- PGID=1000 - PGID=1000
- TZ=Europe/London - TZ=Europe/London
- PASSWORD=password #optional - PASSWORD=password #optional
- SUDO_PASSWORD=password #optional
volumes: volumes:
- /path/to/appdata/config:/config - /path/to/appdata/config:/config
ports: ports:
@ -98,7 +100,8 @@ Container images are configured using parameters passed at runtime (such as thos
| `-e PUID=1000` | for UserID - see below for explanation | | `-e PUID=1000` | for UserID - see below for explanation |
| `-e PGID=1000` | for GroupID - see below for explanation | | `-e PGID=1000` | for GroupID - see below for explanation |
| `-e TZ=Europe/London` | Specify a timezone to use EG Europe/London | | `-e TZ=Europe/London` | Specify a timezone to use EG Europe/London |
| `-e PASSWORD=password` | Optional web gui password, if not provided, there will be no auth | | `-e PASSWORD=password` | Optional web gui password, if not provided, there will be no auth. |
| `-e SUDO_PASSWORD=password` | If this optional variable is set, user will have sudo access in the code-server terminal with the specified password. |
| `-v /config` | Contains all relevant configuration files. | | `-v /config` | Contains all relevant configuration files. |
## User / Group Identifiers ## User / Group Identifiers
@ -192,5 +195,6 @@ Once registered you can define the dockerfile to use with `-f Dockerfile.aarch64
## Versions ## Versions
* **09.07.19:** - Add optional sudo access.
* **01.07.19:** - Add nano. * **01.07.19:** - Add nano.
* **24.06.19:** - Initial Release. * **24.06.19:** - Initial Release.

View File

@ -45,7 +45,8 @@ param_env_vars:
# optional container parameters # optional container parameters
opt_param_usage_include_env: true opt_param_usage_include_env: true
opt_param_env_vars: opt_param_env_vars:
- { env_var: "PASSWORD", env_value: "password", desc: "Optional web gui password, if not provided, there will be no auth"} - { env_var: "PASSWORD", env_value: "password", desc: "Optional web gui password, if not provided, there will be no auth."}
- { env_var: "SUDO_PASSWORD", env_value: "password", desc: "If this optional variable is set, user will have sudo access in the code-server terminal with the specified password."}
optional_block_1: false optional_block_1: false
optional_block_1_items: "" optional_block_1_items: ""
@ -64,5 +65,6 @@ app_setup_block: |
# changelog # changelog
changelogs: changelogs:
- { date: "09.07.19:", desc: "Add optional sudo access." }
- { date: "01.07.19:", desc: "Add nano." } - { date: "01.07.19:", desc: "Add nano." }
- { date: "24.06.19:", desc: "Initial Release." } - { date: "24.06.19:", desc: "Initial Release." }

View File

@ -2,7 +2,16 @@
mkdir -p /config/{extensions,data,workspace,.ssh} mkdir -p /config/{extensions,data,workspace,.ssh}
if [ -n ${SUDO_PASSWORD} ]; then
echo "setting up sudo access"
if [ ! $(cat /etc/sudoers | grep abc) ]; then
echo "adding abc to sudoers"
echo "abc ALL=(ALL:ALL) ALL" >> /etc/sudoers
fi
echo "setting sudo password"
echo -e "${SUDO_PASSWORD}\n${SUDO_PASSWORD}" | passwd abc
fi
# permissions # permissions
chown -R abc:abc \ chown -R abc:abc \
/opt/code-server \
/config /config