summarylogtreecommitdiffstats
path: root/start.sh
diff options
context:
space:
mode:
authorYidaozhan Ya2023-08-27 07:46:33 +0800
committerYidaozhan Ya2023-08-27 07:46:33 +0800
commit728f858782567d4d65eefa5ee1d5eb2f40de48e8 (patch)
treedbf2e812bcaafeedc30919aee4662925917ed0ad /start.sh
parent89e771dd2f04c5dbb2616404d9b59d1ff26f2ca1 (diff)
downloadaur-728f858782567d4d65eefa5ee1d5eb2f40de48e8.tar.gz
[fix] 修复 systemd-homed 兼容问题; 在没有时区时报错
Diffstat (limited to 'start.sh')
-rwxr-xr-xstart.sh27
1 files changed, 27 insertions, 0 deletions
diff --git a/start.sh b/start.sh
index a11ac5c8ff9e..7423472188b2 100755
--- a/start.sh
+++ b/start.sh
@@ -1,5 +1,30 @@
#!/bin/bash
+function command_exists() {
+ local command="$1"
+ command -v "${command}" >/dev/null 2>&1
+}
+
+function show_error_dialog() {
+ title="linuxqq-nt-bwrap"
+ if command_exists kdialog; then
+ kdialog --error "$1" --title "$title" --icon qq
+ elif command_exists zenity; then
+ zenity --error --title "$title" --icon-name qq --text "$1"
+ else
+ all_off="$(tput sgr0)"
+ bold="${all_off}$(tput bold)"
+ blue="${bold}$(tput setaf 4)"
+ yellow="${bold}$(tput setaf 3)"
+ printf "${blue}==>${yellow} ${bold} $1${all_off}\n"
+ fi
+}
+
+if [ -e "/etc/localtime" ]; then
+ show_error_dialog "/etc/localtime 未找到。\n请先设置系统时区。"
+ exit 1
+fi
+
USER_RUN_DIR="/run/user/$(id -u)"
XAUTHORITY="${XAUTHORITY:-$HOME/.Xauthority}"
XDG_CONFIG_HOME="${XDG_CONFIG_HOME:-$HOME/.config}"
@@ -79,6 +104,8 @@ bwrap --new-session --cap-drop ALL --unshare-user-try --unshare-pid --unshare-cg
--dev-bind /dev /dev \
--ro-bind /sys /sys \
--ro-bind /etc/passwd /etc/passwd \
+ --ro-bind /etc/nsswitch.conf /etc/nsswitch.conf \
+ --ro-bind-try /run/systemd/userdb /run/systemd/userdb \
--ro-bind /etc/resolv.conf /etc/resolv.conf \
--ro-bind /etc/localtime /etc/localtime \
--proc /proc \