Skip to content

Commit b722cd6

Browse files
committed
optional sudo password via env variable
1 parent 886c479 commit b722cd6

File tree

4 files changed

+20
-4
lines changed

4 files changed

+20
-4
lines changed

Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ RUN \
1515
apt-get install -y \
1616
git \
1717
nano \
18-
net-tools && \
18+
net-tools \
19+
sudo && \
1920
echo "**** install code-server ****" && \
2021
if [ -z ${CODE_RELEASE+x} ]; then \
2122
CODE_RELEASE=$(curl -sX GET "https://api.github.com/repos/cdr/code-server/releases/latest" \

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ docker create \
5858
-e PGID=1000 \
5959
-e TZ=Europe/London \
6060
-e PASSWORD=password `#optional` \
61+
-e SUDO_PASSWORD=password `#optional` \
6162
-p 8443:8443 \
6263
-v /path/to/appdata/config:/config \
6364
--restart unless-stopped \
@@ -81,6 +82,7 @@ services:
8182
- PGID=1000
8283
- TZ=Europe/London
8384
- PASSWORD=password #optional
85+
- SUDO_PASSWORD=password #optional
8486
volumes:
8587
- /path/to/appdata/config:/config
8688
ports:
@@ -98,7 +100,8 @@ Container images are configured using parameters passed at runtime (such as thos
98100
| `-e PUID=1000` | for UserID - see below for explanation |
99101
| `-e PGID=1000` | for GroupID - see below for explanation |
100102
| `-e TZ=Europe/London` | Specify a timezone to use EG Europe/London |
101-
| `-e PASSWORD=password` | Optional web gui password, if not provided, there will be no auth |
103+
| `-e PASSWORD=password` | Optional web gui password, if not provided, there will be no auth. |
104+
| `-e SUDO_PASSWORD=password` | If this optional variable is set, user will have sudo access in the code-server terminal with the specified password. |
102105
| `-v /config` | Contains all relevant configuration files. |
103106

104107
## User / Group Identifiers
@@ -192,5 +195,6 @@ Once registered you can define the dockerfile to use with `-f Dockerfile.aarch64
192195

193196
## Versions
194197

198+
* **09.07.19:** - Add optional sudo access.
195199
* **01.07.19:** - Add nano.
196200
* **24.06.19:** - Initial Release.

readme-vars.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ param_env_vars:
4545
# optional container parameters
4646
opt_param_usage_include_env: true
4747
opt_param_env_vars:
48-
- { env_var: "PASSWORD", env_value: "password", desc: "Optional web gui password, if not provided, there will be no auth"}
48+
- { env_var: "PASSWORD", env_value: "password", desc: "Optional web gui password, if not provided, there will be no auth."}
49+
- { 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."}
4950

5051
optional_block_1: false
5152
optional_block_1_items: ""
@@ -64,5 +65,6 @@ app_setup_block: |
6465
6566
# changelog
6667
changelogs:
68+
- { date: "09.07.19:", desc: "Add optional sudo access." }
6769
- { date: "01.07.19:", desc: "Add nano." }
6870
- { date: "24.06.19:", desc: "Initial Release." }

root/etc/cont-init.d/30-config

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,16 @@
22

33
mkdir -p /config/{extensions,data,workspace,.ssh}
44

5+
if [ -n ${SUDO_PASSWORD} ]; then
6+
echo "setting up sudo access"
7+
if [ ! $(cat /etc/sudoers | grep abc) ]; then
8+
echo "adding abc to sudoers"
9+
echo "abc ALL=(ALL:ALL) ALL" >> /etc/sudoers
10+
fi
11+
echo "setting sudo password"
12+
echo -e "${SUDO_PASSWORD}\n${SUDO_PASSWORD}" | passwd abc
13+
fi
14+
515
# permissions
616
chown -R abc:abc \
7-
/opt/code-server \
817
/config

0 commit comments

Comments
 (0)