File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -74,7 +74,10 @@ COPY --from=builder /tmp/s6_noarch.tar.xz /tmp/s6_noarch.tar.xz
7474RUN tar -xJf /tmp/s6_noarch.tar.xz -C / && rm -rf /tmp/s6_noarch.tar.xz
7575RUN tar -xJf /tmp/s6_arch.tar.xz -C / && rm -rf /tmp/s6_arch.tar.xz
7676COPY docker/s6-rc.d /etc/s6-overlay/s6-rc.d
77+ COPY docker/s6-overlay/scripts/sync-autostart /etc/s6-overlay/scripts/sync-autostart
78+ RUN chmod +x /etc/s6-overlay/scripts/sync-autostart
7779ENV S6_CMD_WAIT_FOR_SERVICES=1
80+ ENV S6_STAGE2_HOOK=/etc/s6-overlay/scripts/sync-autostart
7881
7982ENTRYPOINT ["/init" ]
8083
Original file line number Diff line number Diff line change @@ -89,6 +89,8 @@ mkdir -p /root/ShellCrash
8989docker run -d \
9090 ………………
9191 -v shellcrash_configs:/etc/ShellCrash/configs \
92+ -v shellcrash_yamls:/etc/ShellCrash/yamls \
93+ -v shellcrash_jsons:/etc/ShellCrash/jsons \
9294 ………………
9395```
9496
@@ -134,7 +136,7 @@ docker rm -f shellcrash
134136### Docker删除卷
135137
136138``` shell
137- docker volume rm shellcrash_configs
139+ docker volume rm shellcrash_configs shellcrash_yamls shellcrash_jsons
138140```
139141
140142### Compose删除容器&卷
Original file line number Diff line number Diff line change @@ -18,10 +18,14 @@ services:
1818 # - net.ipv6.conf.all.forwarding=1
1919 volumes :
2020 - shellcrash_configs:/etc/ShellCrash/configs:rw
21+ - shellcrash_yamls:/etc/ShellCrash/yamls:rw
22+ - shellcrash_jsons:/etc/ShellCrash/jsons:rw
2123 restart : unless-stopped
2224
2325volumes :
2426 shellcrash_configs :
27+ shellcrash_yamls :
28+ shellcrash_jsons :
2529
2630networks :
2731 macvlan_lan :
Original file line number Diff line number Diff line change 1+ #! /bin/sh
2+ # 在 s6-rc 编译 user bundle 之前,把 configs 卷中的自启状态同步到 contents.d
3+ # 由 S6_STAGE2_HOOK 调用;删除重建容器后仍可按 volume 恢复开机自启
4+
5+ CRASHDIR=/etc/ShellCrash
6+ CFG_MARK=" $CRASHDIR /configs/.autostart"
7+ S6_MARK=/etc/s6-overlay/s6-rc.d/user/contents.d/afstart
8+
9+ mkdir -p " $CRASHDIR /configs" /etc/s6-overlay/s6-rc.d/user/contents.d
10+
11+ # 兼容旧容器:仅有 s6 标记时迁移到 configs
12+ if [ -f " $S6_MARK " ] && [ ! -f " $CFG_MARK " ]; then
13+ touch " $CFG_MARK "
14+ fi
15+
16+ if [ -f " $CFG_MARK " ] && [ ! -f " $CRASHDIR /.dis_startup" ]; then
17+ touch " $S6_MARK "
18+ else
19+ rm -f " $S6_MARK "
20+ fi
21+
22+ exit 0
Original file line number Diff line number Diff line change 1+ # s6 / Docker:自启状态以 configs 卷内标记为准,并同步到 s6 contents.d
2+
3+ enable_s6_autostart_marks () {
4+ mkdir -p " $CRASHDIR /configs" /etc/s6-overlay/s6-rc.d/user/contents.d
5+ touch " $CRASHDIR /configs/.autostart" /etc/s6-overlay/s6-rc.d/user/contents.d/afstart
6+ }
7+
8+ disable_s6_autostart_marks () {
9+ rm -f " $CRASHDIR /configs/.autostart" /etc/s6-overlay/s6-rc.d/user/contents.d/afstart
10+ }
11+
12+ # 将旧版仅写在可写层的 s6 标记迁移到 configs
13+ migrate_s6_autostart_mark () {
14+ if [ -f /etc/s6-overlay/s6-rc.d/user/contents.d/afstart ] && [ ! -f " $CRASHDIR /configs/.autostart" ]; then
15+ mkdir -p " $CRASHDIR /configs"
16+ touch " $CRASHDIR /configs/.autostart"
17+ fi
18+ }
19+
120check_autostart (){
221 if [ " $start_old " = ON ]; then
322 [ ! -f " $CRASHDIR " /.dis_startup ] && return 0
@@ -7,7 +26,8 @@ check_autostart(){
726 elif ckcmd systemctl; then
827 [ " $( systemctl is-enabled shellcrash.service 2>&1 ) " = enabled ] && return 0
928 elif grep -q ' s6' /proc/1/comm; then
10- [ -f /etc/s6-overlay/s6-rc.d/user/contents.d/afstart ] && return 0
29+ migrate_s6_autostart_mark
30+ [ -f " $CRASHDIR /configs/.autostart" ] && [ ! -f " $CRASHDIR " /.dis_startup ] && return 0
1131 elif rc-status -r > /dev/null 2>&1 ; then
1232 rc-update show default | grep -q " shellcrash" && return 0
1333 else
Original file line number Diff line number Diff line change @@ -12,15 +12,15 @@ allow_autostart() {
1212 fi
1313
1414 ckcmd systemctl && systemctl enable shellcrash.service > /dev/null 2>&1
15- grep -q ' s6' /proc/1/comm && touch /etc/s6-overlay/s6-rc.d/user/contents.d/afstart
15+ grep -q ' s6' /proc/1/comm && enable_s6_autostart_marks
1616 rc-status -r > /dev/null 2>&1 && rc-update add shellcrash default > /dev/null 2>&1
1717 rm -rf " $CRASHDIR " /.dis_startup
1818}
1919
2020disable_autostart () {
2121 [ -d /etc/rc.d ] && cd /etc/rc.d && rm -rf * shellcrash > /dev/null 2>&1 && cd - > /dev/null
2222 ckcmd systemctl && systemctl disable shellcrash.service > /dev/null 2>&1
23- grep -q ' s6' /proc/1/comm && rm -rf /etc/s6-overlay/s6-rc.d/user/contents.d/afstart
23+ grep -q ' s6' /proc/1/comm && disable_s6_autostart_marks
2424 rc-status -r > /dev/null 2>&1 && rc-update del shellcrash default > /dev/null 2>&1
2525 touch " $CRASHDIR " /.dis_startup
2626}
Original file line number Diff line number Diff line change @@ -69,6 +69,7 @@ forwhat() {
6969 fi
7070
7171 ckcmd systemctl && [ " $( cat /proc/1/comm) " = " systemd" ] && systemctl enable shellcrash.service > /dev/null 2>&1
72+ grep -q ' s6' /proc/1/comm && enable_s6_autostart_marks
7273 rm -rf " $CRASHDIR " /.dis_startup
7374 autostart=enable
7475 # 检测IP转发
Original file line number Diff line number Diff line change 1111. " $CRASHDIR " /libs/set_config.sh
1212. " $CRASHDIR " /libs/set_cron.sh
1313. " $CRASHDIR " /libs/check_cmd.sh
14+ . " $CRASHDIR " /libs/check_autostart.sh
1415. " $CRASHDIR " /libs/compare.sh
1516. " $CRASHDIR " /libs/logger.sh
1617. " $CRASHDIR " /libs/web_save.sh
5455 systemctl start shellcrash.service || . " $CRASHDIR " /starts/start_error.sh
5556 elif grep -q ' s6' /proc/1/comm; then
5657 bfstart && /command/s6-svc -u /run/service/shellcrash && {
57- [ ! -f " $CRASHDIR " /.dis_startup ] && touch /etc/s6-overlay/s6-rc.d/user/contents.d/afstart
58+ [ ! -f " $CRASHDIR " /.dis_startup ] && enable_s6_autostart_marks
5859 afstart &
5960 }
6061 elif rc-status -r > /dev/null 2>&1 ; then
You can’t perform that action at this time.
0 commit comments