aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.editorconfig3
-rw-r--r--dictionary.txt4
-rw-r--r--services/docker/auto-backup/Dockerfile5
-rwxr-xr-xservices/docker/auto-backup/daemon.bash20
-rw-r--r--services/docker/auto-backup/rclone.conf4
-rw-r--r--services/templates/docker-compose.yaml.template2
-rw-r--r--services/templates/envs/auto-backup.env.template9
-rw-r--r--services/templates/envs/mailserver.env.template (renamed from services/templates/envs/mailserver.env)18
-rw-r--r--store/home/config/mihomo/config.yaml94
-rw-r--r--store/home/config/nvim/lua/setup/plugins/cmp.lua5
-rw-r--r--store/home/config/nvim/lua/setup/plugins/telescope.lua19
-rw-r--r--store/misc/magic/extend-script.js21
-rw-r--r--store/misc/magic/extend.yaml65
-rw-r--r--www/assets/res/css/todos.css20
-rw-r--r--www/content/notes/_index.md5
-rw-r--r--www/content/notes/cheat-sheet.md14
-rw-r--r--www/content/notes/hurd.md (renamed from www/content/hurd/_index.md)105
-rw-r--r--www/content/notes/hurd/todos.md (renamed from www/content/hurd/todos.md)14
-rw-r--r--www/content/notes/todos.md (renamed from www/content/todos.md)2
-rw-r--r--www/content/posts/_index.md (renamed from www/content/posts/_index.html)0
-rw-r--r--www/content/posts/c-func-ext.md94
-rw-r--r--www/layouts/_default/list.html11
-rw-r--r--www/layouts/index.html21
-rw-r--r--www/layouts/shortcodes/todo.html6
24 files changed, 331 insertions, 230 deletions
diff --git a/.editorconfig b/.editorconfig
index d28b4e3..4ff2eca 100644
--- a/.editorconfig
+++ b/.editorconfig
@@ -15,6 +15,9 @@ tab_width = 8
indent_size = 2
max_line_length = 80
+[*.{sh,bash}]
+indent_size = 2
+
[*.{html,css,js,ts}]
indent_size = 2
diff --git a/dictionary.txt b/dictionary.txt
index 139dee0..c89911c 100644
--- a/dictionary.txt
+++ b/dictionary.txt
@@ -50,6 +50,7 @@ sourceware
zstd
btrfs
pacman
+rclone
# hurd
gnumach
@@ -73,9 +74,6 @@ sbuild
sbuildrc
schroot
-# commercial
-myqcloud
-
# misc
geodata
geoip
diff --git a/services/docker/auto-backup/Dockerfile b/services/docker/auto-backup/Dockerfile
index e376174..147be21 100644
--- a/services/docker/auto-backup/Dockerfile
+++ b/services/docker/auto-backup/Dockerfile
@@ -1,13 +1,12 @@
FROM debian
RUN apt-get update && apt-get install -y \
- tini ca-certificates coreutils tar zstd \
+ tini ca-certificates coreutils tar zstd rclone \
&& rm -rf /var/lib/apt/lists/*
ENV CRUPEST_AUTO_BACKUP_INIT_DELAY=
ENV CRUPEST_AUTO_BACKUP_INTERVAL=1d
-ADD --chmod=755 https://github.com/tencentyun/coscli/releases/download/v1.0.3/coscli-v1.0.3-linux-amd64 /app/coscli
-ADD daemon.bash /app/
+ADD daemon.bash rclone.conf /app/
VOLUME [ "/data" ]
diff --git a/services/docker/auto-backup/daemon.bash b/services/docker/auto-backup/daemon.bash
index ff670e3..da9f853 100755
--- a/services/docker/auto-backup/daemon.bash
+++ b/services/docker/auto-backup/daemon.bash
@@ -20,16 +20,17 @@ if [[ -z "$CRUPEST_AUTO_BACKUP_INTERVAL" ]]; then
fi
note "Checking secrets..."
-[[ -n "$CRUPEST_AUTO_BACKUP_COS_ENDPOINT" ]] || die "COS endpoint not set!"
-[[ -n "$CRUPEST_AUTO_BACKUP_COS_BUCKET" ]] || die "COS bucket not set!"
-[[ -n "$CRUPEST_AUTO_BACKUP_COS_SECRET_ID" ]] || die "COS secret ID not set!"
-[[ -n "$CRUPEST_AUTO_BACKUP_COS_SECRET_KEY" ]] || die "COS secret key not set!"
+[[ -n "$RCLONE_S3_PROVIDER" ]] || die "S3 provider not set!"
+[[ -n "$RCLONE_S3_ENDPOINT" ]] || die "S3 endpoint not set!"
+[[ -n "$RCLONE_S3_ACCESS_KEY_ID" ]] || die "S3 AccessKey ID not set!"
+[[ -n "$RCLONE_S3_SECRET_ACCESS_KEY" ]] || die "S3 AccessKey Secret not set!"
+[[ -n "$CRUPEST_AUTO_BACKUP_S3_BUCKET" ]] || die "S3 bucket not set!"
success "Secrets check passed."
note "Checking tools..."
tar --version
zstd --version
-/app/coscli --version
+rclone --version
success "Tools check passed."
echo "Backup interval set to $CRUPEST_AUTO_BACKUP_INTERVAL..."
@@ -57,13 +58,10 @@ function backup {
du -h "$tmp_file" | cut -f1 | xargs echo "Size of $tmp_file:"
des_file_name="$current_time.$backup_file_ext"
- echo "Upload $des_file_name to COS..."
+ echo "Upload $des_file_name to S3..."
- /app/coscli --init-skip \
- --secret-id "${CRUPEST_AUTO_BACKUP_COS_SECRET_ID}" \
- --secret-key "${CRUPEST_AUTO_BACKUP_COS_SECRET_KEY}" \
- --endpoint "${CRUPEST_AUTO_BACKUP_COS_ENDPOINT}" \
- cp "$tmp_file" "cos://${CRUPEST_AUTO_BACKUP_COS_BUCKET}/$des_file_name"
+ rclone --config=/app/rclone.conf copyto \
+ "$tmp_file" "remote://${CRUPEST_AUTO_BACKUP_S3_BUCKET}/$des_file_name"
echo "Remove tmp file..."
rm "$tmp_file"
diff --git a/services/docker/auto-backup/rclone.conf b/services/docker/auto-backup/rclone.conf
new file mode 100644
index 0000000..bfcbbc3
--- /dev/null
+++ b/services/docker/auto-backup/rclone.conf
@@ -0,0 +1,4 @@
+[remote]
+type = s3
+env_auth = true
+no_head = true
diff --git a/services/templates/docker-compose.yaml.template b/services/templates/docker-compose.yaml.template
index e133462..ddd3c95 100644
--- a/services/templates/docker-compose.yaml.template
+++ b/services/templates/docker-compose.yaml.template
@@ -47,7 +47,7 @@ services:
restart: on-failure:3
mailserver:
- image: docker.io/mailserver/docker-mailserver:latest
+ image: ghcr.io/docker-mailserver/docker-mailserver:latest
pull_policy: always
container_name: mailserver
hostname: mail.@@CRUPEST_DOMAIN@@
diff --git a/services/templates/envs/auto-backup.env.template b/services/templates/envs/auto-backup.env.template
index c2a6ba9..59d5fed 100644
--- a/services/templates/envs/auto-backup.env.template
+++ b/services/templates/envs/auto-backup.env.template
@@ -1,4 +1,5 @@
-CRUPEST_AUTO_BACKUP_COS_ENDPOINT=@@CRUPEST_AUTO_BACKUP_COS_ENDPOINT@@
-CRUPEST_AUTO_BACKUP_COS_BUCKET=@@CRUPEST_AUTO_BACKUP_COS_BUCKET@@
-CRUPEST_AUTO_BACKUP_COS_SECRET_ID=@@CRUPEST_AUTO_BACKUP_COS_SECRET_ID@@
-CRUPEST_AUTO_BACKUP_COS_SECRET_KEY=@@CRUPEST_AUTO_BACKUP_COS_SECRET_KEY@@
+RCLONE_S3_PROVIDER=@@CRUPEST_AUTO_BACKUP_S3_PROVIDER@@
+RCLONE_S3_ENDPOINT=@@CRUPEST_AUTO_BACKUP_S3_ENDPOINT@@
+RCLONE_S3_ACCESS_KEY_ID=@@CRUPEST_AUTO_BACKUP_S3_ACCESS_KEY_ID@@
+RCLONE_S3_SECRET_ACCESS_KEY=@@CRUPEST_AUTO_BACKUP_S3_ACCESS_KEY_SECRET@@
+CRUPEST_AUTO_BACKUP_S3_BUCKET=@@CRUPEST_AUTO_BACKUP_S3_BUCKET@@
diff --git a/services/templates/envs/mailserver.env b/services/templates/envs/mailserver.env.template
index 9b12dfe..dffb0e8 100644
--- a/services/templates/envs/mailserver.env
+++ b/services/templates/envs/mailserver.env.template
@@ -89,10 +89,10 @@ TLS_LEVEL=
# Configures the handling of creating mails with forged sender addresses.
#
# **0** => (not recommended) Mail address spoofing allowed. Any logged in user may create email messages with a forged sender address (see also https://en.wikipedia.org/wiki/Email_spoofing).
-# 1 => Mail spoofing denied. Each user may only send with his own or his alias addresses. Addresses with extension delimiters(http://www.postfix.org/postconf.5.html#recipient_delimiter) are not able to send messages.
+# 1 => Mail spoofing denied. Each user may only send with their own or their alias addresses. Addresses with extension delimiters(http://www.postfix.org/postconf.5.html#recipient_delimiter) are not able to send messages.
SPOOF_PROTECTION=
-# Enables the Sender Rewriting Scheme. SRS is needed if your mail server acts as forwarder. See [postsrsd](https://github.com/roehling/postsrsd/blob/master/README.md#sender-rewriting-scheme-crash-course) for further explanation.
+# Enables the Sender Rewriting Scheme. SRS is needed if your mail server acts as forwarder. See [postsrsd](https://github.com/roehling/postsrsd/blob/main/README.rst) for further explanation.
# - **0** => Disabled
# - 1 => Enabled
ENABLE_SRS=0
@@ -154,7 +154,7 @@ ENABLE_RSPAMD_REDIS=
#
# **0** => disabled
# 1 => enabled
-RSPAMD_LEARN=0
+RSPAMD_LEARN=1
# This settings controls whether checks should be performed on emails coming
# from authenticated users (i.e. most likely outgoing emails). The default value
@@ -171,7 +171,7 @@ RSPAMD_CHECK_AUTHENTICATED=0
#
# **0** => disabled
# 1 => enabled
-RSPAMD_GREYLISTING=1
+RSPAMD_GREYLISTING=0
# Can be used to enable or disable the Hfilter group module.
#
@@ -508,7 +508,7 @@ DOVECOT_MAILBOX_FORMAT=maildir
# empty => no
# yes => Allow bind authentication for LDAP
-# https://wiki.dovecot.org/AuthDatabase/LDAP/AuthBinds
+# https://doc.dovecot.org/2.4.0/core/config/auth/databases/ldap.html#authentication-bind
DOVECOT_AUTH_BIND=
# -----------------------------------------------
@@ -631,7 +631,7 @@ SRS_SECRET=
#
# Set a default host to relay all mail through (optionally include a port)
# Example: [mail.example.com]:587
-DEFAULT_RELAY_HOST=
+DEFAULT_RELAY_HOST=@@CRUPEST_MAIL_SERVER_RELAY@@
# -----------------------------------------------
# --- Multi-Domain Relay Section ----------------
@@ -646,7 +646,7 @@ RELAY_HOST=
# empty => 25
# default port to relay mail
-RELAY_PORT=25
+RELAY_PORT=@@CRUPEST_MAIL_SERVER_RELAY_PORT@@
# -----------------------------------------------
# --- Relay Host Credentials Section ------------
@@ -655,7 +655,7 @@ RELAY_PORT=25
# Configure a relay user and password to use with RELAY_HOST / DEFAULT_RELAY_HOST
# empty => no default
-RELAY_USER=
+RELAY_USER=@@CRUPEST_MAIL_SERVER_RELAY_USER@@
# empty => no default
-RELAY_PASSWORD=
+RELAY_PASSWORD=@@CRUPEST_MAIL_SERVER_RELAY_PASSWORD@@
diff --git a/store/home/config/mihomo/config.yaml b/store/home/config/mihomo/config.yaml
new file mode 100644
index 0000000..72d9ae7
--- /dev/null
+++ b/store/home/config/mihomo/config.yaml
@@ -0,0 +1,94 @@
+mixed-port: 7897
+mode: rule
+log-level: info
+external-controller: 127.0.0.1:9090
+profile:
+ store-selected: true
+
+external-ui: /usr/share/metacubexd
+external-ui-name: metacubexd
+external-ui-url: https://github.com/MetaCubeX/metacubexd/archive/refs/heads/gh-pages.zip
+
+geox-url:
+ geoip: https://testingcf.jsdelivr.net/gh/MetaCubeX/meta-rules-dat@release/geoip.dat
+ geosite: https://testingcf.jsdelivr.net/gh/MetaCubeX/meta-rules-dat@release/geosite.dat
+ mmdb: https://testingcf.jsdelivr.net/gh/MetaCubeX/meta-rules-dat@release/country.mmdb
+ asn: https://testingcf.jsdelivr.net/gh/MetaCubeX/meta-rules-dat@release/GeoLite2-ASN.mmdb
+geo-auto-update: true
+geo-update-interval: 24
+
+ipv6: false
+unified-delay: true
+global-client-fingerprint: edge
+
+dns:
+ enable: true
+ ipv6: true
+ default-nameserver:
+ - 223.5.5.5
+ nameserver:
+ - https://dns.alidns.com/dns-query
+ - 223.5.5.5
+ - 8.8.8.8
+ - 1.1.1.1
+
+rules:
+ - GEOSITE,github,node-select
+ - GEOSITE,google,node-select
+ - GEOSITE,youtube,node-select
+ - GEOSITE,twitter,node-select
+ - GEOSITE,facebook,node-select
+ - GEOSITE,discord,node-select
+ - GEOSITE,reddit,node-select
+ - GEOSITE,twitch,node-select
+ - GEOSITE,quora,node-select
+ - GEOSITE,telegram,node-select
+ - GEOSITE,imgur,node-select
+ - GEOSITE,stackexchange,node-select
+ - GEOSITE,onedrive,node-select
+ - GEOSITE,duckduckgo,node-select
+ - GEOSITE,wikimedia,node-select
+ - GEOSITE,gitbook,node-select
+ - GEOSITE,gitlab,node-select
+ - GEOSITE,creativecommons,node-select
+ - GEOSITE,archive,node-select
+ - GEOSITE,matrix,node-select
+ - GEOSITE,tor,node-select
+ - GEOSITE,python,node-select
+ - GEOSITE,ruby,node-select
+ - GEOSITE,rust,node-select
+ - GEOSITE,nodejs,node-select
+ - GEOSITE,npmjs,node-select
+ - GEOSITE,qt,node-select
+ - GEOSITE,docker,node-select
+ - GEOSITE,v2ray,node-select
+ - GEOSITE,homebrew,node-select
+ - GEOSITE,bootstrap,node-select
+ - GEOSITE,heroku,node-select
+ - GEOSITE,vercel,node-select
+ - GEOSITE,ieee,node-select
+ - GEOSITE,sci-hub,node-select
+ - GEOSITE,libgen,node-select
+ - DOMAIN-SUFFIX,gnu.org,node-select
+ - DOMAIN-SUFFIX,nongnu.org,node-select
+ - DOMAIN-SUFFIX,ietf.org,node-select
+ - DOMAIN-SUFFIX,packagist.org,node-select
+ - DOMAIN-SUFFIX,metacubex.one,node-select
+ - MATCH,DIRECT
+
+proxy-groups:
+ - name: node-select
+ type: select
+ proxies:
+ - auto-select
+ use:
+ - money
+
+ - name: auto-select
+ type: url-test
+ use:
+ - money
+ interval: 300
+ url: https://www.gstatic.com/generate_204
+ filter: 日本|新加坡|香港|台湾|美国
+ expected-status: 204
diff --git a/store/home/config/nvim/lua/setup/plugins/cmp.lua b/store/home/config/nvim/lua/setup/plugins/cmp.lua
index c977943..be9f8ea 100644
--- a/store/home/config/nvim/lua/setup/plugins/cmp.lua
+++ b/store/home/config/nvim/lua/setup/plugins/cmp.lua
@@ -7,15 +7,12 @@ local function setup()
vim.snippet.expand(args.body)
end,
},
- window = {
- completion = cmp.config.window.bordered(),
- documentation = cmp.config.window.bordered(),
- },
mapping = cmp.mapping.preset.insert({
['<C-b>'] = cmp.mapping.scroll_docs(-4),
['<C-f>'] = cmp.mapping.scroll_docs(4),
['<C-j>'] = cmp.mapping.select_next_item({ behavior = cmp.SelectBehavior.Select }),
['<C-k>'] = cmp.mapping.select_prev_item({ behavior = cmp.SelectBehavior.Select }),
+ ['<C-e>'] = cmp.mapping.abort(),
['<C-y>'] = cmp.mapping.confirm({ select = true }),
['<CR>'] = cmp.mapping.confirm({ select = true }),
}),
diff --git a/store/home/config/nvim/lua/setup/plugins/telescope.lua b/store/home/config/nvim/lua/setup/plugins/telescope.lua
index d68b7f2..69a69c0 100644
--- a/store/home/config/nvim/lua/setup/plugins/telescope.lua
+++ b/store/home/config/nvim/lua/setup/plugins/telescope.lua
@@ -1,9 +1,26 @@
local function setup()
local builtin = require('telescope.builtin')
- vim.keymap.set('n', '<leader>ff', builtin.find_files, {})
+ vim.keymap.set('n', '<leader>/', builtin.live_grep, {})
vim.keymap.set('n', '<leader>fg', builtin.live_grep, {})
+ vim.keymap.set('n', '<leader>ff', builtin.find_files, {})
vim.keymap.set('n', '<leader>fb', builtin.buffers, {})
vim.keymap.set('n', '<leader>fh', builtin.help_tags, {})
+ vim.keymap.set('n', '<leader>fr', builtin.registers, {})
+ vim.keymap.set('n', '<leader>fq', builtin.quickfixhistory, {})
+ vim.keymap.set('n', '<leader>fm', builtin.marks, {})
+ vim.keymap.set('n', '<leader>fd', builtin.diagnostics, {})
+ vim.keymap.set('n', '<leader>fs', builtin.lsp_workspace_symbols, {})
+
+ local function all_files(opts)
+ opts = vim.tbl_extend('force', {
+ hidden = true,
+ no_ignore = true,
+ no_ignore_parent = true,
+ }, opts or {})
+ builtin.find_files(opts)
+ end
+
+ vim.keymap.set('n', '<leader>fa', all_files, {})
end
return {
diff --git a/store/misc/magic/extend-script.js b/store/misc/magic/extend-script.js
deleted file mode 100644
index 519cee9..0000000
--- a/store/misc/magic/extend-script.js
+++ /dev/null
@@ -1,21 +0,0 @@
-// Define main function (script entry)
-
-function main(config, profileName) {
- delete config.dns;
- delete config.tun;
- delete config.hosts;
-
- delete config["cfw-latency-timeout"]
- delete config["cfw-latency-url"]
- delete config["cfw-conn-break-strategy"]
-
- config["proxies"] = [config["crupest-proxy"], ...config["proxies"]]
- delete config["crupest-proxy"]
-
- select_proxy = { name: "node-select", type: "select", proxies: ["auto-select", ...config.proxies.map(p => p.name)] }
- auto_select_proxy = config["crupest-auto-select"]
- config["proxy-groups"] = [ select_proxy, auto_select_proxy ]
- delete config["crupest-auto-select"]
-
- return config;
-}
diff --git a/store/misc/magic/extend.yaml b/store/misc/magic/extend.yaml
deleted file mode 100644
index 3006f08..0000000
--- a/store/misc/magic/extend.yaml
+++ /dev/null
@@ -1,65 +0,0 @@
-# Profile Enhancement Merge Template for Clash Verge
-
-profile:
- store-selected: true
-
-rules:
- - "GEOSITE,github,node-select"
- - "GEOSITE,google,node-select"
- - "GEOSITE,youtube,node-select"
- - "GEOSITE,twitter,node-select"
- - "GEOSITE,facebook,node-select"
- - "GEOSITE,discord,node-select"
- - "GEOSITE,reddit,node-select"
- - "GEOSITE,twitch,node-select"
- - "GEOSITE,quora,node-select"
- - "GEOSITE,telegram,node-select"
- - "GEOSITE,imgur,node-select"
- - "GEOSITE,stackexchange,node-select"
- - "GEOSITE,onedrive,node-select"
-
- - "GEOSITE,duckduckgo,node-select"
- - "GEOSITE,wikimedia,node-select"
- - "GEOSITE,gitbook,node-select"
- - "GEOSITE,gitlab,node-select"
- - "GEOSITE,creativecommons,node-select"
- - "GEOSITE,archive,node-select"
- - "GEOSITE,matrix,node-select"
- - "GEOSITE,tor,node-select"
-
- - "GEOSITE,python,node-select"
- - "GEOSITE,ruby,node-select"
- - "GEOSITE,rust,node-select"
- - "GEOSITE,nodejs,node-select"
- - "GEOSITE,npmjs,node-select"
- - "GEOSITE,qt,node-select"
- - "GEOSITE,docker,node-select"
- - "GEOSITE,v2ray,node-select"
- - "GEOSITE,homebrew,node-select"
- - "GEOSITE,bootstrap,node-select"
-
- - "GEOSITE,heroku,node-select"
- - "GEOSITE,vercel,node-select"
-
- - "GEOSITE,ieee,node-select"
- - "GEOSITE,sci-hub,node-select"
- - "GEOSITE,libgen,node-select"
-
- - "DOMAIN-SUFFIX,gnu.org,node-select"
- - "DOMAIN-SUFFIX,nongnu.org,node-select"
- - "DOMAIN-SUFFIX,ietf.org,node-select"
- - "DOMAIN-SUFFIX,packagist.org,node-select"
- - "DOMAIN-SUFFIX,metacubex.one,node-select"
- - "MATCH,DIRECT"
-
-crupest-proxy:
- ...
-
-crupest-auto-select:
- name: "auto-select"
- type: url-test
- interval: 1800
- include-all-proxies: true
- url: 'https://www.gstatic.com/generate_204'
- filter: "日本|新加坡|香港|台湾|美国"
- expected-status: 204
diff --git a/www/assets/res/css/todos.css b/www/assets/res/css/todos.css
index e9a595d..7802812 100644
--- a/www/assets/res/css/todos.css
+++ b/www/assets/res/css/todos.css
@@ -1,14 +1,24 @@
.todo {
-
- &::before {
+ h3::before {
font-family: monospace;
}
- &.working::before {
+ &.working h3::before {
content: "* ";
}
- &.done::before {
+ &.done h3::before {
content: "✓ ";
}
-} \ No newline at end of file
+
+ &.give-up {
+ &, a:link, a:visited {
+ color: grey;
+ }
+
+ h3:before {
+ content: "orz ✖ ";
+ }
+ }
+}
+
diff --git a/www/content/notes/_index.md b/www/content/notes/_index.md
new file mode 100644
index 0000000..3c736ed
--- /dev/null
+++ b/www/content/notes/_index.md
@@ -0,0 +1,5 @@
+---
+title: "Notes"
+params:
+ recursive: true
+---
diff --git a/www/content/notes/cheat-sheet.md b/www/content/notes/cheat-sheet.md
new file mode 100644
index 0000000..efb3b35
--- /dev/null
+++ b/www/content/notes/cheat-sheet.md
@@ -0,0 +1,14 @@
+---
+title: "Cheat Sheet"
+date: 2025-04-01T23:09:53+08:00
+lastmod: 2025-04-01T23:09:53+08:00
+---
+
+Update GRUB after `grub` package is updated. Replace `/boot` with your mount
+point of the EFI partition in `--efi-directory=/boot`. Replace `GRUB` with your
+bootloader id in `--bootloader-id=GRUB`.
+
+```bash-session
+grub-install --target=x86_64-efi --efi-directory=/boot --bootloader-id=GRUB
+grub-mkconfig -o /boot/grub/grub.cfg
+```
diff --git a/www/content/hurd/_index.md b/www/content/notes/hurd.md
index b4c727c..67b8df9 100644
--- a/www/content/hurd/_index.md
+++ b/www/content/notes/hurd.md
@@ -2,12 +2,11 @@
title: "Hurd"
date: 2025-03-03T15:34:41+08:00
lastmod: 2025-03-03T23:28:46+08:00
-layout: single
---
{{< mono >}}
-[TODOS](/hurd/todos)
+[TODOS](/notes/hurd/todos)
{{< /mono >}}
@@ -41,100 +40,48 @@ refs:
## *_MAX patch
-TODO: Move to separate page.
-
-```c
-#include <errno.h>
-#include <stdlib.h>
-#include <unistd.h>
-
-static inline char *xreadlink(const char *restrict path) {
- char *buffer;
- size_t allocated = 128;
- ssize_t len;
-
- while (1) {
- buffer = (char *)malloc(allocated);
- if (!buffer) {
- return NULL;
- }
- len = readlink(path, buffer, allocated);
- if (len < (ssize_t)allocated) {
- return buffer;
- }
- free(buffer);
- if (len >= (ssize_t)allocated) {
- allocated *= 2;
- continue;
- }
- return NULL;
- }
-}
-
-static inline char *xgethostname() {
- long max_host_name;
- char *buffer;
-
- max_host_name = sysconf(_SC_HOST_NAME_MAX);
- buffer = malloc(max_host_name + 1);
-
- if (gethostname(buffer, max_host_name + 1)) {
- free(buffer);
- return NULL;
- }
-
- buffer[max_host_name] = '\0';
- return buffer;
-}
-
-static inline char *xgetcwd() {
- char *buffer;
- size_t allocated = 128;
-
- while (1) {
- buffer = (char *)malloc(allocated);
- if (!buffer) {
- return NULL;
- }
- getcwd(buffer, allocated);
- if (buffer)
- return buffer;
- free(buffer);
- if (errno == ERANGE) {
- allocated *= 2;
- continue;
- }
- return NULL;
- }
-}
-```
+See [this](posts/c-func-ext.md)
## git repos
+Clone all at once:
+
+```sh
+# glibc is too big, so not clone here.
+for repo in hurd gnumach mig web; do
+ if [ ! -d $repo ]; then
+ git clone "https://crupest.life/git/hurd/$repo.git"
+ pushd $repo
+ git remote add upstream "https://git.savannah.gnu.org/git/hurd/$repo.git"
+ popd
+ fi
+done
+```
+
{{< link-group >}}
hurd
-cru: <https://crupest.life/git/cru-hurd/hurd.git>
+cru: <https://crupest.life/git/hurd/hurd.git>
upstream: <https://git.savannah.gnu.org/git/hurd/hurd.git>
debian: <https://salsa.debian.org/hurd-team/hurd>
{{< /link-group >}}
{{< link-group >}}
gnumach
-cru: <https://crupest.life/git/cru-hurd/gnumach.git>
+cru: <https://crupest.life/git/hurd/gnumach.git>
upstream: <https://git.savannah.gnu.org/git/hurd/gnumach.git>
debian: <https://salsa.debian.org/hurd-team/gnumach>
{{< /link-group >}}
{{< link-group >}}
mig
-cru: <https://crupest.life/git/cru-hurd/mig.git>
+cru: <https://crupest.life/git/hurd/mig.git>
upstream: <https://git.savannah.gnu.org/git/hurd/mig.git>
debian: <https://salsa.debian.org/hurd-team/mig>
{{< /link-group >}}
{{< link-group >}}
glibc
-cru: <https://crupest.life/git/cru-hurd/glibc.git>
+cru: <https://crupest.life/git/hurd/glibc.git>
upstream: <git://sourceware.org/git/glibc.git>
debian: <https://salsa.debian.org/glibc-team/glibc>
mirror: <https://mirrors.tuna.tsinghua.edu.cn/git/glibc.git>
@@ -142,7 +89,7 @@ mirror: <https://mirrors.tuna.tsinghua.edu.cn/git/glibc.git>
{{< link-group >}}
web
-cru: <https://crupest.life/git/cru-hurd/web.git>
+cru: <https://crupest.life/git/hurd/web.git>
upstream: <https://git.savannah.gnu.org/git/hurd/web.git>
{{< /link-group >}}
@@ -151,14 +98,18 @@ upstream: <https://git.savannah.gnu.org/git/hurd/web.git>
Start qemu
```sh
-qemu-system-x86_64 -enable-kvm -m 4G -net nic -net user,hostfwd=tcp::3222-:22 -vga vmware -drive cache=writeback,file=[...]
+qemu-system-x86_64 -enable-kvm -m 4G \
+ -net nic -net user,hostfwd=tcp::3222-:22 \
+ -vga vmware -drive cache=writeback,file=[...]
```
Configure/Setup network
```sh
-settrans -fgap /servers/socket/2 /hurd/pfinet -i /dev/eth0 -a 10.0.2.15 -g 10.0.2.2 -m 255.255.255.0
-fsysopts /servers/socket/2 /hurd/pfinet -i /dev/eth0 -a 10.0.2.15 -g 10.0.2.2 -m 255.255.255.0
+settrans -fgap /servers/socket/2 /hurd/pfinet \
+ -i /dev/eth0 -a 10.0.2.15 -g 10.0.2.2 -m 255.255.255.0
+fsysopts /servers/socket/2 /hurd/pfinet \
+ -i /dev/eth0 -a 10.0.2.15 -g 10.0.2.2 -m 255.255.255.0
fsysopts /server/socket/2 -a 10.0.2.15 -g 10.0.2.2 -m 255.255.255.0
```
diff --git a/www/content/hurd/todos.md b/www/content/notes/hurd/todos.md
index f8273fb..cd93f01 100644
--- a/www/content/hurd/todos.md
+++ b/www/content/notes/hurd/todos.md
@@ -9,7 +9,7 @@ params:
## Porting
-### {{< todo name=pam state=working >}}
+{{< todo name=pam state=give-up >}}
{{< link-group >}}
git
@@ -23,7 +23,9 @@ mail
<https://lists.debian.org/debian-hurd/2025/02/msg00018.html>
{{< /link-group >}}
-### {{< todo name=abseil state=working >}}
+{{< /todo >}}
+
+{{< todo name=abseil state=working >}}
{{< link-group >}}
git
@@ -38,7 +40,9 @@ mail
<https://lists.debian.org/debian-hurd/2025/02/msg00035.html>
{{< /link-group >}}
-### {{< todo name=libgav1 state=done >}}
+{{< /todo >}}
+
+{{< todo name=libgav1 state=done >}}
{{< link-group >}}
git
@@ -52,3 +56,7 @@ misc
mail: <https://lists.debian.org/debian-hurd/2025/02/msg00016.html>
gerrit: <https://chromium-review.googlesource.com/c/codecs/libgav1/+/6239812>
{{< /link-group >}}
+
+{{< /todo >}}
+
+
diff --git a/www/content/todos.md b/www/content/notes/todos.md
index a790e24..1625362 100644
--- a/www/content/todos.md
+++ b/www/content/notes/todos.md
@@ -4,4 +4,4 @@ date: 2025-03-03T15:34:53+08:00
lastmod: 2025-03-03T23:28:46+08:00
---
-[Hurd](/hurd/todos)
+[Hurd](/notes/hurd/todos)
diff --git a/www/content/posts/_index.html b/www/content/posts/_index.md
index 76fa783..76fa783 100644
--- a/www/content/posts/_index.html
+++ b/www/content/posts/_index.md
diff --git a/www/content/posts/c-func-ext.md b/www/content/posts/c-func-ext.md
index f5ab8fb..7106fad 100644
--- a/www/content/posts/c-func-ext.md
+++ b/www/content/posts/c-func-ext.md
@@ -8,16 +8,92 @@ tags:
- posix
---
-Recently, I've been working on porting libraries to GNU/Hurd. The maintainers of GNU/Hurd
-have a strong belief that [`*_MAX` macros on POSIX system interfaces](https://pubs.opengroup.org/onlinepubs/9699919799.2008edition/nframe.html)
-are very evil things. This is indeed true as a lot of (old) libraries relying on those macros
-to determine the buffer size. In modern programming world, it is definitely a bad
-idea to use fixed values for buffer sizes without considering possible overflow, unless
-you are certain that size is sufficient.
-
-When you get rid of some old things, you will always meet compatibility problems. In these
-case, old source codes using these macros just do not compile now. So here are some
+Recently, I’ve been working on porting some libraries to GNU/Hurd. Many (old)
+libraries use [`*_MAX` constants on POSIX system
+interfaces](https://pubs.opengroup.org/onlinepubs/9699919799.2008edition/nframe.html)
+to calculate buffer sizes. However, the GNU/Hurd maintainers urge against the
+blind use of them and refuse to define them in system headers. When old APIs are
+gone, compatibility problems come. To make my life easier, I'll put some
+reusable code snippets here to help *fix `*_MAX` bugs*.
<!--more-->
+```c
+#include <stdlib.h>
+#include <stdarg.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <errno.h>
+
+static inline char *xreadlink(const char *restrict path) {
+ char *buffer;
+ size_t allocated = 128;
+ ssize_t len;
+
+ while (1) {
+ buffer = (char*) malloc(allocated);
+ if (!buffer) { return NULL; }
+ len = readlink(path, buffer, allocated);
+ if (len < (ssize_t) allocated) { return buffer; }
+ free(buffer);
+ if (len >= (ssize_t) allocated) { allocated *= 2; continue; }
+ return NULL;
+ }
+ }
+
+
+static inline char *xgethostname(void) {
+ long max_host_name;
+ char *buffer;
+
+ max_host_name = sysconf(_SC_HOST_NAME_MAX);
+ buffer = malloc(max_host_name + 1);
+
+ if (gethostname(buffer, max_host_name + 1)) {
+ free(buffer);
+ return NULL;
+ }
+
+ buffer[max_host_name] = '\0';
+ return buffer;
+}
+
+static inline char *xgetcwd(void) {
+ char *buffer;
+ size_t allocated = 128;
+
+ while (1) {
+ buffer = (char*) malloc(allocated);
+ if (!buffer) { return NULL; }
+ getcwd(buffer, allocated);
+ if (buffer) return buffer;
+ free(buffer);
+ if (errno == ERANGE) { allocated *= 2; continue; }
+ return NULL;
+ }
+}
+
+static inline __attribute__((__format__(__printf__, 2, 3))) int
+xsprintf(char **buf_ptr, const char *restrict format, ...) {
+ char *buffer;
+ int ret;
+
+ va_list args;
+ va_start(args, format);
+
+ ret = snprintf(NULL, 0, format, args);
+ if (ret < 0) { goto out; }
+
+ buffer = malloc(ret + 1);
+ if (!buffer) { ret = -1; goto out; }
+
+ ret = snprintf(NULL, 0, format, args);
+ if (ret < 0) { free(buffer); goto out; }
+
+ *buf_ptr = buffer;
+out:
+ va_end(args);
+ return ret;
+}
+```
diff --git a/www/layouts/_default/list.html b/www/layouts/_default/list.html
index c7c6cce..5bb0b5e 100644
--- a/www/layouts/_default/list.html
+++ b/www/layouts/_default/list.html
@@ -4,9 +4,14 @@
{{ define "content" }}
{{ partial "nav.html" . }}
- <h1>Posts</h1>
+ <h1>{{ .Title }}</h1>
+ {{ $pages := .RegularPages }}
+ {{ if .Param "recursive" }}
+ {{ $pages = .RegularPagesRecursive }}
+ {{ end }}
{{ partial "preview/posts.html" (dict
- "h" "h3"
- "pages" (.RegularPages.ByDate.Reverse.Limit 3))
+ "h" "h3"
+ "pages" $pages
+ )
}}
{{ end }}
diff --git a/www/layouts/index.html b/www/layouts/index.html
index 7c608f1..e05af03 100644
--- a/www/layouts/index.html
+++ b/www/layouts/index.html
@@ -26,23 +26,26 @@
<hr />
<section>
<p>Welcome to my home page! Nice to meet you here! 🥰</p>
- <p>If you have something interesting to share with me, feel free to email me at
- <a rel="noopener noreferrer" href="mailto:crupest@crupest.life">crupest@crupest.life</a>.
- You can also create an issue in any of my repos on GitHub to talk anything to me.
+ <p>If you have something interesting to share with me, feel free to email me
+ at <a rel="noopener noreferrer" href="mailto:crupest@crupest.life">crupest@crupest.life</a>.
+ You can also create an issue in any of my repos
+ on <a rel="noopener noreferrer" href="https://github.com/crupest">GitHub</a> to talk
+ anything to me.
</p>
<div id="links" class="mono-link">
- links:
+ goto:
<ul>
- <li><a href="{{ .RelPermalink }}">home</a></li>
<li><a href="{{ absURL "/git/" }}">git</a></li>
- {{ with .GetPage "/hurd" }}
+ {{ with .GetPage "/notes/hurd" }}
<li><a href="{{ .RelPermalink }}">hurd</a></li>
{{ end }}
- {{ with .GetPage "/todos" }}
+ {{ with .GetPage "/notes/todos" }}
<li><a href="{{ .RelPermalink }}">todos</a></li>
{{ end }}
- <li><a rel="noopener noreferrer" href="https://github.com/crupest">github</a></li>
- </ul>
+ {{ with .GetPage "/notes/cheat-sheet" }}
+ <li><a href="{{ .RelPermalink }}">cheat-sheet</a></li>
+ {{ end }}
+ </ul>
</div>
</section>
<hr>
diff --git a/www/layouts/shortcodes/todo.html b/www/layouts/shortcodes/todo.html
index 1327b31..b4fc680 100644
--- a/www/layouts/shortcodes/todo.html
+++ b/www/layouts/shortcodes/todo.html
@@ -1 +1,5 @@
-<span class="todo {{ .Get "state" }}">{{ .Get "name" }}</span> \ No newline at end of file
+<section class="todo {{ .Get "state" }}">
+ <h3>{{ .Get "name" }}</h3>
+ {{ .Inner }}
+</section>
+