{"id":22437231,"url":"https://github.com/ustclug/liimstrap","last_synced_at":"2025-08-01T15:32:03.322Z","repository":{"id":20771369,"uuid":"24056127","full_name":"ustclug/liimstrap","owner":"ustclug","description":"中国科大图书馆查询机生成脚本","archived":false,"fork":false,"pushed_at":"2024-09-14T03:18:00.000Z","size":1517,"stargazers_count":14,"open_issues_count":3,"forks_count":5,"subscribers_count":11,"default_branch":"master","last_synced_at":"2024-09-14T16:11:32.763Z","etag":null,"topics":["linux"],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ustclug.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2014-09-15T12:49:09.000Z","updated_at":"2024-05-11T16:59:05.000Z","dependencies_parsed_at":"2024-09-14T16:21:38.163Z","dependency_job_id":null,"html_url":"https://github.com/ustclug/liimstrap","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ustclug%2Fliimstrap","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ustclug%2Fliimstrap/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ustclug%2Fliimstrap/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ustclug%2Fliimstrap/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ustclug","download_url":"https://codeload.github.com/ustclug/liimstrap/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228389156,"owners_count":17912189,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["linux"],"created_at":"2024-12-06T00:12:13.111Z","updated_at":"2025-08-01T15:32:03.274Z","avatar_url":"https://github.com/ustclug.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# liimstrap\n\n中国科大图书馆图书查询机自动生成脚本，当前版本基于 Debian Bookworm 开发。\n\n话说，LIIMS 是嘛意思？我猜是 Library Independent Inquery Machine System 吧。\n\n## 依赖\n\n参见 [Dockerfile](Dockerfile)。\n\n## 生成\n\n```sh\nsudo ./liimstrap \u003cROOT\u003e\n```\n\nROOT 是存放镜像根文件系统的目录。\n\n镜像的 root 密码可以通过 `ROOT_PASSWORD` 环境变量提供。\n\n`etc/authorized_keys` 文件里放的是 root 远程 SSH 登录的公钥。\n\n## 压成 SqaushFS 镜像\n\n```sh\nsudo ./deploy \u003cROOT\u003e \u003cDEST\u003e\n```\n\n会在 DEST 目录中创建三个文件：\n\n- `vmlinuz` 是内核\n- `initrd.img` 是 initrd\n- `root.sfs` 是根目录的镜像\n\nGRUB 配置参见 `grub.example` 文件。\n\n## 从 Docker 构建\n\n```sh\n# docker build -t ustclug/liimstrap:liims-2 .\n# docker run -it --privileged --rm -v $DATA_PATH:/srv/dest -e ROOT_PASSWORD=test ustclug/liimstrap:liims-2  # 此命令创建 rootfs 内容\n# docker run -it --privileged --rm -v $DATA_PATH:/srv/dest -e ROOT_PASSWORD=test -e SQUASHFS=true ustclug/liimstrap:liims-2  # 此命令创建 rootfs 内容并打包为 squashfs\n```\n\n## 本地调试\n\n1. 安装 NFS Server（`nfs-kernel-server`）\n2. 配置 `/etc/exports` 如下：\n\n   ```sh\n   /liims\tlocalhost(ro,no_root_squash,async,insecure,no_subtree_check)\n   ```\n\n   其中 /liims 是生成文件所在的目录。编辑完成后，执行 `exportfs -ra` 命令更新。\n\n3. 使用以下参数启动 qemu：\n\n   ```sh\n   qemu-system-x86_64 -kernel ./vmlinuz -initrd ./initrd.img -m 700m -machine accel=kvm -append \"nfsroot=10.0.2.2:/liims ip=dhcp boot=nfs\"\n   ```\n\n   你的当前所在目录需要有生成的 vmlinuz 和 initrd.img 文件，内存等参数可以按需调整。\n\n   如果是 squashfs，那么参数对应是：\n\n   ```sh\n   qemu-system-x86_64 -kernel ./vmlinuz -initrd ./initrd.img -m 700m -machine accel=kvm -append \"nfsroot=10.0.2.2:/liims ip=dhcp boot=nfs squashfs=root.sfs\"\n   ```\n\n## 技术细节\n\n见 `docs` 目录。\n\n## 附录\n\n### 在非科大校园网环境构建\n\n写入 `/etc/resolv.conf` 的步骤执行后，之后的相关命令连接网络时会请求 `202.38.64.1` 作为 DNS 服务器，在校外环境下可能无法使用。这个问题可以使用 iptables 处理：\n\n```\n# 在 NAT 表中修改包的目的地（假设本地 DNS 为 127.0.0.53）\niptables -t nat -A OUTPUT -d 202.38.64.1/32 -p udp -m udp --dport 53 -j DNAT --to-destination 127.0.0.53:53\niptables -t nat -A OUTPUT -d 202.38.64.1/32 -p tcp -m tcp --dport 53 -j DNAT --to-destination 127.0.0.53:53\n# 如果使用 systemd-resolved，其要求访问的 IP 必须为本地回环，但是访问 202.38.64.1 的路由不是本地回环\n# 因此包的源地址也需要修改\niptables -t nat -A POSTROUTING -d 127.0.0.53/32 -p udp -m udp --dport 53 -j SNAT --to-source 127.0.0.1\niptables -t nat -A POSTROUTING -d 127.0.0.53/32 -p tcp -m tcp --dport 53 -j SNAT --to-source 127.0.0.1\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fustclug%2Fliimstrap","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fustclug%2Fliimstrap","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fustclug%2Fliimstrap/lists"}