13
13
14
14
# Exit on errors
15
15
set -Ee
16
+ set -x
17
+
16
18
17
19
# Global Vars
18
20
CN_CONFIG_USER=$( whoami)
19
21
CN_CONFIG_CONFIGFILE=" tools/.config"
20
22
CN_CONFIG_ROOTPATH=" /home/${CN_CONFIG_USER} /printer_data"
21
- CN_CONFIG_CONFIGPATH=" ${CN_CONFIG_ROOTPATH} /config"
22
- CN_CONFIG_LOGPATH=" ${CN_CONFIG_ROOTPATH} /logs"
23
- CN_CONFIG_ENVPATH=" ${CN_CONFIG_ROOTPATH} /systemd"
24
- CN_MOONRAKER_CONFIG_PATH=" ${CN_CONFIG_CONFIGPATH} /moonraker.conf"
23
+ # CN_CONFIG_CONFIGPATH="${CN_CONFIG_ROOTPATH}/config"
24
+ # CN_CONFIG_LOGPATH="${CN_CONFIG_ROOTPATH}/logs"
25
+ # CN_CONFIG_ENVPATH="${CN_CONFIG_ROOTPATH}/systemd"
26
+ # CN_MOONRAKER_CONFIG_PATH="${CN_CONFIG_CONFIGPATH}/moonraker.conf"
25
27
CN_USTREAMER_REPO=" https://github.com/pikvm/ustreamer.git"
26
28
CN_USTREAMER_BRANCH=" master"
27
29
CN_CAMERA_STREAMER_REPO=" https://github.com/ayufan-research/camera-streamer.git"
@@ -56,6 +58,14 @@ default_path_msg() {
56
58
echo -e " Hit ENTER to use default."
57
59
}
58
60
61
+ root_path_msg () {
62
+ header_msg
63
+ echo -e " Please specify path to your 'printer_data' root path\n"
64
+ echo -e " For example: /home/pi/voron_data or /home/kwad/ender_data"
65
+ echo -e " \t\e[34mNOTE:\e[0m File names are hardcoded! Also skip trailing backslash!"
66
+ echo -e " \tDefault: \e[32m${CN_CONFIG_ROOTPATH} \e[0m\n"
67
+ }
68
+
59
69
config_path_msg () {
60
70
header_msg
61
71
echo -e " Please specify path to config file (crowsnest.conf)\n"
@@ -149,11 +159,31 @@ create_config_header() {
149
159
} >> " ${CN_CONFIG_CONFIGFILE} "
150
160
}
151
161
162
+ specify_root_path () {
163
+ local reply
164
+ root_path_msg
165
+ default_path_msg
166
+ read -erp " Please enter path: " reply
167
+ if [[ -z " ${reply} " ]]; then
168
+ echo -e " CROWSNEST_CONFIG_PATH=\" ${CN_CONFIG_CONFIGPATH} \" " >> \
169
+ " ${CN_CONFIG_CONFIGFILE} "
170
+ return 0
171
+ fi
172
+ if [[ -n " ${reply} " ]]; then
173
+ CN_CONFIG_ROOTPATH=" ${reply} "
174
+ CN_CONFIG_CONFIGPATH=" ${CN_CONFIG_ROOTPATH} /config"
175
+ CN_CONFIG_LOGPATH=" ${CN_CONFIG_ROOTPATH} /logs"
176
+ CN_CONFIG_ENVPATH=" ${CN_CONFIG_ROOTPATH} /systemd"
177
+ CN_MOONRAKER_CONFIG_PATH=" ${CN_CONFIG_CONFIGPATH} /moonraker.conf"
178
+ return 0
179
+ fi
180
+ }
181
+
152
182
specify_config_path () {
153
183
local reply
154
184
config_path_msg
155
185
default_path_msg
156
- read -erp " Please enter path: " reply
186
+ read -erp " Please enter path: " -i " ${CN_CONFIG_CONFIGPATH} " reply
157
187
if [[ -z " ${reply} " ]]; then
158
188
echo -e " CROWSNEST_CONFIG_PATH=\" ${CN_CONFIG_CONFIGPATH} \" " >> \
159
189
" ${CN_CONFIG_CONFIGFILE} "
@@ -170,7 +200,7 @@ specify_log_path() {
170
200
local reply
171
201
log_path_msg
172
202
default_path_msg
173
- read -erp " Please enter path: " reply
203
+ read -erp " Please enter path: " -i " ${CN_CONFIG_LOGPATH} " reply
174
204
if [[ -z " ${reply} " ]]; then
175
205
echo -e " CROWSNEST_LOG_PATH=\" ${CN_CONFIG_LOGPATH} \" " >> \
176
206
" ${CN_CONFIG_CONFIGFILE} "
@@ -186,7 +216,7 @@ specify_env_path() {
186
216
local reply
187
217
env_path_msg
188
218
default_path_msg
189
- read -erp " Please enter path: " reply
219
+ read -erp " Please enter path: " -i " ${CN_CONFIG_ENVPATH} " reply
190
220
if [[ -z " ${reply} " ]]; then
191
221
echo -e " CROWSNEST_ENV_PATH=\" ${CN_CONFIG_ENVPATH} \" " >> \
192
222
" ${CN_CONFIG_CONFIGFILE} "
@@ -223,22 +253,15 @@ add_moonraker_entry() {
223
253
224
254
# ## Main func
225
255
main () {
226
- # Step 1: Welcome Message
227
256
welcome_msg
228
257
continue_config
229
- # Step 2: Check for existing file
230
258
check_config_file
231
- # Step 3: Create config header
232
259
create_config_header
233
- # Step 4: Specify config file path.
260
+ specify_root_path
234
261
specify_config_path
235
- # Step 5: Specify log file path.
236
262
specify_log_path
237
- # Step 6: Specify env path.
238
263
specify_env_path
239
- # Step 7: Moonraker entry
240
264
add_moonraker_entry
241
- # Step 8: Display finished message
242
265
goodbye_msg
243
266
}
244
267
0 commit comments