Skip to content

startup script #753

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
antofthy opened this issue Jun 6, 2019 · 12 comments
Closed

startup script #753

antofthy opened this issue Jun 6, 2019 · 12 comments
Labels
enhancement Some improvement that isn't a feature

Comments

@antofthy
Copy link

antofthy commented Jun 6, 2019

The following is a script I wrote to start code-server in the background,
or if already running, to report the current password needed to connect to it.
With options to KILL or WATCH and KILL the code-server on shell exit.

Ideas and suggestions are welcome...

start-code-server

@antofthy antofthy added the enhancement Some improvement that isn't a feature label Jun 6, 2019
@fbartels
Copy link

fbartels commented Jun 6, 2019

Hi @antofthy,

small initial suggestion, maybe you could put your script in a Gist instead of attaching it as a file to this issue.

@sr229
Copy link
Contributor

sr229 commented Jun 6, 2019

Also my suggestion:

  • I don't think there's a necessity for this, especially for Linux systems, init systems serves as service managers and serves the same purpose as well. You just need to register code-server as a service, making the script pointless.

  • your script is just needlessly wrapping what code-server can already do. Making it even more pointless. I say we just put this into upstream instead of abstracting it further.

@antofthy
Copy link
Author

antofthy commented Jun 7, 2019

The reason for this is that code-server is being run by students in a docker environment (one per user), as necessary. The password information was being output with a lot of other information that is not really useful to the user. It also continuously logs to std-out other unwanted information, making it very horrible to simply run in background.

Even if we start code-server automatically as a service (which we did not want), the student still needs to be able to get the password they will be using. So even then, a script to report that password easily was needed.

And finally localhost was not the correct URL for the student to put into their browser!

@fbartels Thanks for the tip about Gist didn't know about it.

@deansheather
Copy link
Member

If you're looking to run code-server for many students at once, I'd recommend generating a random password yourself and then passing it as an environment variable to code-server. Then the password would be consistent between runs. If you also kept the hostname/port details the same for each student, then you could just email the student their details one-time or something instead of them having to get a new password each time.

@sr229
Copy link
Contributor

sr229 commented Jun 7, 2019

That's what I exactly thought as well @deansheather, I also recommend using VMs if your systems are designed to be type 1 hypervisors for your students.

@Josh-Uvi
Copy link

Josh-Uvi commented Jun 8, 2019

If you're looking to run code-server for many students at once, I'd recommend generating a random password yourself and then passing it as an environment variable to code-server. Then the password would be consistent between runs. If you also kept the hostname/port details the same for each student, then you could just email the student their details one-time or something instead of them having to get a new password each time.

@deansheather @sr229
please I need help to setup a Custom Systemd Service for code-server on Ubuntu 18.0.4
Here is my code
[Unit]
Description=Code Server AutoStart
After=http://network.target

[Service]
Type=simple
User=$USER
WorkingDirectory=/path/to/start/your/working/directory/inside/vscode
LimitNOFILE=infinity
LimitNPROC=infinity
LimitCORE=infinity
Restart=on-failure

ExecStart=/path/to/codeserver/binary --allow-http --password=xxxxxxx cert=/path/fullchain.pem cert-key=/path/fullchain.pem

[Install]
WantedBy=http://multi-user.target

But it doesn't work with the password. How can I improve this code to make it work? Also, I would like to add my letsencrypt certificate to secure it. Thanks

@deansheather
Copy link
Member

@Josh-Uvi please open a new issue as this is unrelated.

@antofthy
Copy link
Author

antofthy commented Jun 10, 2019

@Josh-Uvi thank you for the systemd service file, I have noted it for possible use in the future.
Though we prefer students to start code-server when they want it, with a random password.
The start-code-server script was purely to simplify this for the students.
Fixing the password in this way would not be very good security wise.

@Merith-TK
Copy link
Contributor

@Josh-Uvi I have my service file free to download at https://merith.tk/vscode.service

just tweak it to your needs and you should do well
this will start a code-server instance on port 8443 without a password, as user vscode with rw perms only on /opt/code-server/ and /home/vscode as i didnt know how to change home directories on users at the time

@arvati
Copy link

arvati commented Jun 14, 2019

I used this script to start on alpine linux machine.
I liked the idea of showing address and password when you run "service status" and will improve my gist soon.

@antofthy
Copy link
Author

The start-code-server script is now used to start code-server in a php:7.3-apache container, extracting and reporting the random password it generates to the "docker service logs" for that container. The Container control program pick up the password from there to pass on to the containers owner as needed.

@nhooyr
Copy link
Contributor

nhooyr commented Jan 28, 2020

We're gonna take care of this soon. Duplicate of #164

@nhooyr nhooyr closed this as completed Jan 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Some improvement that isn't a feature
Projects
None yet
Development

No branches or pull requests

8 participants