-
Notifications
You must be signed in to change notification settings - Fork 0
/
cli.sh
126 lines (97 loc) · 2.57 KB
/
cli.sh
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
#! /bin/bash
# Check if the correct number of arguments is provided
if [ "$#" -lt 2 ]; then
echo "Usage: mlci <command> <argument>"
echo "See https://help.moonlightpanel.xyz/cli for all commands"
exit 1
fi
# Assign the first argument to a variable
command=$1
# Assign the second argument to a variable
argument=$2
# Define commands
## Moonlight
moonlightConfig () {
nano /var/lib/docker/volumes/moonlight/_data/configs/core.json
echo -e "\n"
echo "Done? If you are finished with your adjustment, run the following command to apply changes"
echo "'mlcli moonlight restart'"
}
moonlightLogin () {
echo "Searching for default login in moonlight logs"
docker logs moonlight | grep "Default login: Email: "
}
moonlightRestart () {
docker restart moonlight_db
docker restart moonlight
}
moonlightLogs () {
docker logs moonlight
}
## Daemon
daemonConfig () {
nano /etc/moonlight/config.json
echo -e "\n"
echo "Done? If you are finished with your adjustment, run the following command to apply changes"
echo "'mlcli daemon restart'"
}
daemonLogs () {
cat /var/log/moonlight.log
}
daemonRestart () {
systemctl restart mldaemon
}
daemonStatus () {
systemctl status mldaemon
}
## Install
installUpdate() {
echo "Updating installer"
if test -f /tmp/Installer; then
rm /tmp/Installer
fi
arch=$(uname -m | grep -q 'x86_64' && echo 'x64' || echo 'arm64')
curl -o /tmp/Installer https://get-moonlight.app/Installer_$arch
}
installRun () {
if ! test -f /tmp/Installer; then
installUpdate
fi
chmod +x /tmp/Installer
sudo /tmp/Installer $*
}
case $command in
moonlight)
if [ "$argument" == "config" ]; then
moonlightConfig
elif [ "$argument" == "login" ]; then
moonlightLogin
elif [ "$argument" == "logs" ]; then
moonlightLogs
elif [ "$argument" == "restart" ]; then
moonlightRestart
fi
;;
daemon)
if [ "$argument" == "config" ]; then
daemonConfig
elif [ "$argument" == "status" ]; then
daemonStatus
elif [ "$argument" == "logs" ]; then
daemonLogs
elif [ "$argument" == "restart" ]; then
daemonRestart
fi
;;
install)
if [ "$argument" == "run" ]; then
installRun $*
elif [ "$argument" == "update" ]; then
installUpdate
fi
;;
*)
echo "Unknown command: $command"
exit 1
;;
esac