[Unit]
Description=Run VS Code on a remote server.
Documentation=https://github.com/cdr/code-server
After=network.target network-online.target

[Service]
Type=simple
User={{ code_server_user }}
{% if code_server_password is defined %}
EnvironmentFile={{ code_server_data_dir_abs }}/env
{% endif %}
ExecStart={{ code_server_bin_dir }}/code-server
 {%- if code_server_major != '1' %} --auth {{ code_server_auth }}{% endif %}
 {%- if code_server_tls_cert is defined %} --cert {{ code_server_data_dir_abs }}/tls.cert{% endif %}
 {%- if code_server_tls_key is defined %} --cert-key {{ code_server_data_dir_abs }}/tls.key{% endif %}
 {%- if code_server_work_dir is defined %} {{ code_server_work_dir }}{% endif %}
 --host {{ code_server_host }} --port {{ code_server_port }}
WorkingDirectory=~

[Install]
WantedBy=multi-user.target
