@@ -109,7 +109,6 @@ FTL_PORT="${RUN_DIRECTORY}/pihole-FTL.port"
109
109
PIHOLE_LOG=" ${LOG_DIRECTORY} /pihole.log"
110
110
PIHOLE_LOG_GZIPS=" ${LOG_DIRECTORY} /pihole.log.[0-9].*"
111
111
PIHOLE_DEBUG_LOG=" ${LOG_DIRECTORY} /pihole_debug.log"
112
- PIHOLE_DEBUG_LOG_SANITIZED=" ${LOG_DIRECTORY} /pihole_debug-sanitized.log"
113
112
PIHOLE_FTL_LOG=" ${LOG_DIRECTORY} /pihole-FTL.log"
114
113
115
114
PIHOLE_WEB_SERVER_ACCESS_LOG_FILE=" ${WEB_SERVER_LOG_DIRECTORY} /access.log"
@@ -209,11 +208,6 @@ log_write() {
209
208
copy_to_debug_log () {
210
209
# Copy the contents of file descriptor 3 into the debug log
211
210
cat /proc/$$ /fd/3 > " ${PIHOLE_DEBUG_LOG} "
212
- # Since we use color codes such as '\e[1;33m', they should be removed before being
213
- # uploaded to our server, since it can't properly display in color
214
- # This is accomplished by use sed to remove characters matching that patter
215
- # The entire file is then copied over to a sanitized version of the log
216
- sed ' s/\[[0-9;]\{1,5\}m//g' > " ${PIHOLE_DEBUG_LOG_SANITIZED} " <<< cat " ${PIHOLE_DEBUG_LOG} "
217
211
}
218
212
219
213
initialize_debug () {
@@ -269,6 +263,9 @@ compare_local_version_to_git_version() {
269
263
# The commit they are on
270
264
local remote_commit
271
265
remote_commit=$( git describe --long --dirty --tags --always)
266
+ # Status of the repo
267
+ local local_status
268
+ local_status=$( git status -s)
272
269
# echo this information out to the user in a nice format
273
270
# If the current version matches what pihole -v produces, the user is up-to-date
274
271
if [[ " ${remote_version} " == " $( pihole -v | awk ' /${search_term}/ {print $6}' | cut -d ' )' -f1) " ]]; then
@@ -291,6 +288,16 @@ compare_local_version_to_git_version() {
291
288
fi
292
289
# echo the current commit
293
290
log_write " ${INFO} Commit: ${remote_commit} "
291
+ # if `local_status` is non-null, then the repo is not clean, display details here
292
+ if [[ ${local_status} ]]; then
293
+ # Replace new lines in the status with 12 spaces to make the output cleaner
294
+ log_write " ${INFO} Status: ${local_status// $' \n ' / ' \n ' } "
295
+ local local_diff
296
+ local_diff=$( git diff)
297
+ if [[ ${local_diff} ]]; then
298
+ log_write " ${INFO} Diff: ${local_diff// $' \n ' / ' \n ' } "
299
+ fi
300
+ fi
294
301
# If git status failed,
295
302
else
296
303
# Return an error message
@@ -1134,20 +1141,20 @@ analyze_pihole_log() {
1134
1141
IFS=" $OLD_IFS "
1135
1142
}
1136
1143
1137
- tricorder_use_nc_or_ssl () {
1138
- # Users can submit their debug logs using nc (unencrypted) or openssl (enrypted ) if available
1139
- # Check for openssl first since encryption is a good thing
1140
- if command -v openssl & > /dev/null; then
1144
+ tricorder_use_nc_or_curl () {
1145
+ # Users can submit their debug logs using nc (unencrypted) or curl (encrypted ) if available
1146
+ # Check for curl first since encryption is a good thing
1147
+ if command -v curl & > /dev/null; then
1141
1148
# If the command exists,
1142
- log_write " * Using ${COL_GREEN} openssl ${COL_NC} for transmission."
1143
- # encrypt and transmit the log and store the token returned in a variable
1144
- tricorder_token=$( < ${PIHOLE_DEBUG_LOG_SANITIZED} openssl s_client -quiet -connect tricorder.pi-hole.net:${TRICORDER_SSL_PORT_NUMBER} 2> /dev/null )
1149
+ log_write " * Using ${COL_GREEN} curl ${COL_NC} for transmission."
1150
+ # transmit he log via TLS and store the token returned in a variable
1151
+ tricorder_token=$( curl --silent --upload-file ${PIHOLE_DEBUG_LOG} https:// tricorder.pi-hole.net:${TRICORDER_SSL_PORT_NUMBER} )
1145
1152
# Otherwise,
1146
1153
else
1147
1154
# use net cat
1148
1155
log_write " ${INFO} Using ${COL_YELLOW} netcat${COL_NC} for transmission."
1149
1156
# Save the token returned by our server in a variable
1150
- tricorder_token=$( < ${PIHOLE_DEBUG_LOG_SANITIZED } nc tricorder.pi-hole.net ${TRICORDER_NC_PORT_NUMBER} )
1157
+ tricorder_token=$( < ${PIHOLE_DEBUG_LOG } nc tricorder.pi-hole.net ${TRICORDER_NC_PORT_NUMBER} )
1151
1158
fi
1152
1159
}
1153
1160
@@ -1173,7 +1180,7 @@ upload_to_tricorder() {
1173
1180
# let the user know
1174
1181
log_write " ${INFO} Debug script running in automated mode"
1175
1182
# and then decide again which tool to use to submit it
1176
- tricorder_use_nc_or_ssl
1183
+ tricorder_use_nc_or_curl
1177
1184
# If we're not running in automated mode,
1178
1185
else
1179
1186
echo " "
@@ -1182,7 +1189,7 @@ upload_to_tricorder() {
1182
1189
read -r -p " [?] Would you like to upload the log? [y/N] " response
1183
1190
case ${response} in
1184
1191
# If they say yes, run our function for uploading the log
1185
- [yY][eE][sS]|[yY]) tricorder_use_nc_or_ssl ;;
1192
+ [yY][eE][sS]|[yY]) tricorder_use_nc_or_curl ;;
1186
1193
# If they choose no, just exit out of the script
1187
1194
* ) log_write " * Log will ${COL_GREEN} NOT${COL_NC} be uploaded to tricorder." ; exit ;
1188
1195
esac
@@ -1209,7 +1216,7 @@ upload_to_tricorder() {
1209
1216
log_write " * Please try again or contact the Pi-hole team for assistance."
1210
1217
fi
1211
1218
# Finally, show where the log file is no matter the outcome of the function so users can look at it
1212
- log_write " * A local copy of the debug log can be found at: ${COL_CYAN}${PIHOLE_DEBUG_LOG_SANITIZED }${COL_NC} \\ n"
1219
+ log_write " * A local copy of the debug log can be found at: ${COL_CYAN}${PIHOLE_DEBUG_LOG }${COL_NC} \\ n"
1213
1220
}
1214
1221
1215
1222
# Run through all the functions we made
0 commit comments