-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSet-GUI_Ubuntu.sh
More file actions
executable file
·64 lines (48 loc) · 1.26 KB
/
Copy pathSet-GUI_Ubuntu.sh
File metadata and controls
executable file
·64 lines (48 loc) · 1.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/bin/sh
# ヘルプメッセージを表示する関数
show_help() {
cat <<EOF
Usage: $(basename "$0")
Description:
Ubuntuの起動モードをGUI (graphical.target) と CUI (multi-user.target) の間で切り替えます。
スクリプトは対話形式で実行され、sudo権限が必要です。
Options:
-h, --help このヘルプメッセージを表示して終了します。
EOF
}
# -h または --help が引数として渡された場合にヘルプを表示
if [ "$1" = "-h" ] || [ "$1" = "--help" ]; then
show_help
exit 0
fi
require_commands() {
missing=0
for cmd in "$@"; do
if ! command -v "$cmd" >/dev/null 2>&1; then
echo "エラー: 必須コマンド '$cmd' が見つかりません。" >&2
missing=1
fi
done
if [ "$missing" -ne 0 ]; then
exit 1
fi
}
require_commands sudo systemctl
echo "set GUI"
echo "e) enable GUI"
echo "d) disable GUI"
read ANS
case "$ANS" in
[eE]) # 大文字のEも受け付けるようにしたぞ
sudo systemctl set-default graphical.target
echo "Boot GUI Mode"
;;
[dD]) # 大文字のDも受け付けるようにしたぞ
sudo systemctl set-default multi-user.target
echo "Boot CUI Mode"
;;
*)
# 何もしない
echo "無効な選択じゃ。スクリプトを終了するぞ。"
;;
esac