Skip to content

Commit e6d2604

Browse files
committed
feat: add code-server
1 parent 724abc4 commit e6d2604

25 files changed

+6925
-2
lines changed

.github/workflows/ghpage.yaml

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
name: gendocs-and-deploy-docs
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- next
8+
- next-major
9+
- '[0-9]+.[0-9]+.x'
10+
- alpha
11+
- beta
12+
- feature/*
13+
- fix/*
14+
pull_request:
15+
branches:
16+
- main
17+
- next
18+
- next-major
19+
- '[0-9]+.[0-9]+.x'
20+
- alpha
21+
- beta
22+
workflow_dispatch:
23+
24+
jobs:
25+
build-and-deploy:
26+
runs-on: ubuntu-latest
27+
28+
steps:
29+
- name: Checkout repository
30+
uses: actions/checkout@v4
31+
with:
32+
fetch-depth: 0
33+
34+
- name: Setup Node.js
35+
uses: actions/setup-node@v4
36+
with:
37+
node-version: 18
38+
39+
- name: Install dependencies
40+
run: npm ci
41+
42+
# - name: Get Tag Version
43+
# id: get_version
44+
# run: echo "VERSION=$(git tag -l --sort=v:refname "v*" | tail -1)" >> $GITHUB_ENV
45+
46+
# - name: Checkout Tag Version
47+
# run: |
48+
# git checkout "${{ env.VERSION }}"
49+
50+
# - name: Update version for package.json
51+
# run: |
52+
# jq '.version = "${{ env.VERSION }}"' package.json > temp.json && mv temp.json package.json
53+
54+
# - name: Run tests
55+
# run: npm test
56+
57+
- name: Generate pages
58+
run: npm run build
59+
60+
- name: Copy files
61+
run: cp code-server dist/get/index.html
62+
63+
- name: Deploy to GitHub Pages
64+
uses: peaceiris/actions-gh-pages@v3
65+
with:
66+
github_token: ${{ secrets.GITHUB_TOKEN }}
67+
publish_dir: ./dist

.gitignore

Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
# build output
2+
dist/
3+
4+
# generated types
5+
.astro/
6+
7+
# vscode
8+
.vscode/
9+
10+
# Logs
11+
logs
12+
*.log
13+
npm-debug.log*
14+
yarn-debug.log*
15+
yarn-error.log*
16+
lerna-debug.log*
17+
.pnpm-debug.log*
18+
19+
# Diagnostic reports (https://nodejs.org/api/report.html)
20+
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
21+
22+
# Runtime data
23+
pids
24+
*.pid
25+
*.seed
26+
*.pid.lock
27+
28+
# Directory for instrumented libs generated by jscoverage/JSCover
29+
lib-cov
30+
31+
# Coverage directory used by tools like istanbul
32+
coverage
33+
*.lcov
34+
35+
# nyc test coverage
36+
.nyc_output
37+
38+
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
39+
.grunt
40+
41+
# Bower dependency directory (https://bower.io/)
42+
bower_components
43+
44+
# node-waf configuration
45+
.lock-wscript
46+
47+
# Compiled binary addons (https://nodejs.org/api/addons.html)
48+
build/Release
49+
50+
# Dependency directories
51+
node_modules/
52+
jspm_packages/
53+
54+
# Snowpack dependency directory (https://snowpack.dev/)
55+
web_modules/
56+
57+
# TypeScript cache
58+
*.tsbuildinfo
59+
60+
# Optional npm cache directory
61+
.npm
62+
63+
# Optional eslint cache
64+
.eslintcache
65+
66+
# Optional stylelint cache
67+
.stylelintcache
68+
69+
# Microbundle cache
70+
.rpt2_cache/
71+
.rts2_cache_cjs/
72+
.rts2_cache_es/
73+
.rts2_cache_umd/
74+
75+
# Optional REPL history
76+
.node_repl_history
77+
78+
# Output of 'npm pack'
79+
*.tgz
80+
81+
# Yarn Integrity file
82+
.yarn-integrity
83+
84+
# dotenv environment variable files
85+
.env
86+
.env.development.local
87+
.env.test.local
88+
.env.production.local
89+
.env.local
90+
91+
# parcel-bundler cache (https://parceljs.org/)
92+
.cache
93+
.parcel-cache
94+
95+
# Next.js build output
96+
.next
97+
out
98+
99+
# Nuxt.js build / generate output
100+
.nuxt
101+
dist
102+
103+
# Gatsby files
104+
.cache/
105+
# Comment in the public line in if your project uses Gatsby and not Next.js
106+
# https://nextjs.org/blog/next-9-1#public-directory-support
107+
# public
108+
109+
# vuepress build output
110+
.vuepress/dist
111+
112+
# vuepress v2.x temp and cache directory
113+
.temp
114+
.cache
115+
116+
# vitepress build output
117+
**/.vitepress/dist
118+
119+
# vitepress cache directory
120+
**/.vitepress/cache
121+
122+
# Docusaurus cache and generated files
123+
.docusaurus
124+
125+
# Serverless directories
126+
.serverless/
127+
128+
# FuseBox cache
129+
.fusebox/
130+
131+
# DynamoDB Local files
132+
.dynamodb/
133+
134+
# TernJS port file
135+
.tern-port
136+
137+
# Stores VSCode versions used for testing VSCode extensions
138+
.vscode-test
139+
140+
# yarn v2
141+
.yarn/cache
142+
.yarn/unplugged
143+
.yarn/build-state.yml
144+
.yarn/install-state.gz
145+
.pnp.*

Makefile

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
TARGET = code-server
2+
SHFMT_OPTS = -i 2 -ci -w
3+
SHELLCHECK_OPTS =
4+
BATS_OPTS =
5+
6+
.PHONY: all
7+
all: fmt lint
8+
9+
.PHONY: fmt
10+
fmt: $(TARGET)
11+
shfmt $(SHFMT_OPTS) $?
12+
13+
.PHONY: lint
14+
lint: $(TARGET)
15+
shellcheck $(SHELLCHECK_OPTS) $?

NOTICE

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
code
2+
Copyright 2025 rising3(Michio Nakagawa)
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1-
# code-server
2-
vscode server
1+
# vscode systemd.service
2+
3+

astro.config.mjs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// @ts-check
2+
import { defineConfig } from "astro/config";
3+
import tailwindcss from "@tailwindcss/vite";
4+
5+
import mdx from "@astrojs/mdx";
6+
7+
export default defineConfig({
8+
site: 'https://rising3.github.io',
9+
base: '/code',
10+
integrations: [mdx()],
11+
vite: {
12+
plugins: [tailwindcss()],
13+
},
14+
});

code-server

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
#!/bin/bash
2+
# Copyright 2025 rising3(Michio Nakagawa)
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
#
16+
17+
set -e
18+
19+
ESC=$(printf '\033')
20+
TARGET_DIR=/home/$USER/.config/systemd/user
21+
22+
function helper_gen() {
23+
cat <<EOS
24+
#!/bin/bash
25+
set -e
26+
27+
ip=\$(ip -4 addr | awk '/state UP/ {i=\$2} /inet / && !f {sub(/\/.*/, "", \$2); if(i~/^e/||i~/^en/) {print \$2; f=1} else if(i~/^w/||i~/^wl/) {print \$2; f=1}} END{if(!f) print "0.0.0.0"}')
28+
29+
echo "\$ip" > "${TARGET_DIR}/code-tmp"
30+
31+
exit 0
32+
EOS
33+
}
34+
35+
function service_gen() {
36+
cat <<EOS
37+
[Unit]
38+
Description=VSCode Server service
39+
After=network-online.target
40+
Wants=network-online.target
41+
42+
[Service]
43+
Type=simple
44+
ExecStartPre=/bin/bash "${TARGET_DIR}/code-helper"
45+
ExecStart=/bin/bash -c '/usr/bin/code serve-web --without-connection-token --accept-server-license-terms --host \$(cat ${TARGET_DIR}/code-tmp)'
46+
ExecStartPost=/bin/bash -c "rm -f ${TARGET_DIR}/code-tmp"
47+
Restart=always
48+
RestartSec=5
49+
50+
[Install]
51+
WantedBy=default.target
52+
EOS
53+
}
54+
55+
function enable_linger() {
56+
if ! sudo loginctl enable-linger "$USER"; then
57+
printf "${ESC}[31m%s${ESC}[m\n" "✖ enable linger failed"
58+
exit 1
59+
fi
60+
printf "${ESC}[33m%s${ESC}[m\n" "✅ enable linger"
61+
exit 0
62+
}
63+
64+
# Array of required commands
65+
required_commands=("awk" "code")
66+
67+
# Check if each command is installed
68+
for cmd in "${required_commands[@]}"; do
69+
if ! command -v "$cmd" &>/dev/null; then
70+
printf "${ESC}[31m%s${ESC}[m\n" "$cmd is not installed. Please install it and try again."
71+
exit 1
72+
fi
73+
done
74+
75+
if [ "$(ps -p 1 -o comm=)" != "systemd" ]; then
76+
printf "${ESC}[31m%s${ESC}[m\n" "✖ This script is only for systemd"
77+
exit 1
78+
fi
79+
80+
if [ "$(loginctl show-user "$USER" | grep 'Linger=yes')" != "Linger=yes" ]; then
81+
enable_linger
82+
fi
83+
84+
if [ "$(systemctl --user is-active code.service)" == "active" ]; then
85+
printf "${ESC}[33m%s${ESC}[m\n" "✅ code.service is already running"
86+
exit 0
87+
fi
88+
89+
mkdir -p "${TARGET_DIR}"
90+
91+
echo -e "$(helper_gen)" >"${TARGET_DIR}/code-helper"
92+
echo -e "$(service_gen)" >"${TARGET_DIR}/code.service"
93+
94+
systemctl --user daemon-reload
95+
systemctl --user enable code.service
96+
systemctl --user start code.service
97+
exit 0

favicon.svg

Lines changed: 9 additions & 0 deletions
Loading

0 commit comments

Comments
 (0)