Ver código fonte

linux script can be used on headless systems

Sergio Brighenti 5 anos atrás
pai
commit
bbf365279d

+ 1 - 0
CHANGELOG.md

@@ -5,6 +5,7 @@
 + Added ability to show a preview of PDF files.
 + Added remember me functionality.
 + Raw URL now accept file extensions.
++ The linux script can be used on headless systems.
 + Improved installer.
 + Improved thumbnail generation.
 + Replaced videojs player with Plyr.

+ 1 - 1
resources/templates/dashboard/system.twig

@@ -164,7 +164,7 @@
                 <div class="card shadow-sm mt-3">
                     <div class="card-header"><i class="fas fa-donate fa-fw"></i> {{ lang('donation') }}</div>
                     <div class="card-body">
-                        <p>{{ lang('donate_text') }}</p>
+                        <p class="text-justify">{{ lang('donate_text') }}</p>
                         <div class="text-center">
                             <a href="https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=6RXF8ZGCZBL68&item_name=Support+the+XBackBone+Development&currency_code=EUR&source=url" target="_blank" class="text-warning"><i class="fab fa-cc-paypal fa-3x"></i></a>
                         </div>

+ 41 - 19
resources/templates/scripts/xbackbone_uploader.sh.twig

@@ -33,40 +33,58 @@ upload() {
     
     if jq -e . >/dev/null 2>&1 <<<"$RESPONSE"; then
         # Response is JSON
-        echo;
+        echo "Upload Completed.";
     else
-        notify-send "Error: Uploading returned unexpected response" "Response: ${RESPONSE}";
+        if [ "${DESKTOP_SESSION}" != "" ]; then
+            notify-send "Error: Uploading returned unexpected response" "Response: ${RESPONSE}";
+        else
+            echo "Error: Uploading returned unexpected response: ${RESPONSE}"
+        fi
         exit 1;
     fi
 
     if [[ "$(echo "${RESPONSE}" | jq -r '.message')" == "OK." ]]; then
         URL="$(echo "${RESPONSE}" | jq -r '.url')";
-        echo "${URL}" | xclip -selection c;
-        notify-send "Upload completed!" "${URL}";
+        if [ "${DESKTOP_SESSION}" != "" ]; then
+            echo "${URL}" | xclip -selection c;
+            notify-send "Upload completed!" "${URL}";
+        else
+            echo "${URL}";
+        fi
     else
-        notify-send "Error!" "$(echo "${RESPONSE}" | jq -r '.message')";
+        if [ "${DESKTOP_SESSION}" != "" ]; then
+            notify-send "Error!" "$(echo "${RESPONSE}" | jq -r '.message')";
+        else
+            echo "Error! $(echo "${RESPONSE}" | jq -r '.message')";
+        fi
     fi
 }
 
 check() {
-	if [ ! -x "$(command -v xclip)" ]; then
-        echo "xclip command not found."
-        exit;
-	fi	
-	
-	if [ ! -x "$(command -v jq)" ]; then
-        echo "jq command not found."
-        exit;
+    ERRORS=0;
+
+    if [ ! -x "$(command -v jq)" ]; then
+        echo "jq command not found.";
+        ERRORS=1;
 	fi	
 
 	if [ ! -x "$(command -v curl)" ]; then
-        echo "curl command not found."
-        exit;
+        echo "curl command not found.";
+        ERRORS=1;
 	fi
 
-	if [ ! -x "$(command -v notify-send)" ]; then
-        echo "notify-send command not found."
-        exit;
+	if [ ! -x "$(command -v xclip)" ] && [ "${DESKTOP_SESSION}" != "" ]; then
+        echo "xclip command not found.";
+        ERRORS=1;
+	fi
+
+	if [ ! -x "$(command -v notify-send)" ] && [ "${DESKTOP_SESSION}" != "" ]; then
+        echo "notify-send command not found.";
+        ERRORS=1;
+	fi
+
+	if [ "${ERRORS}" -eq 1 ]; then
+	  exit 1;
 	fi
 }
 
@@ -80,5 +98,9 @@ fi
 if [ -f "${1}" ]; then
     upload "${1}";
 else
-    notify-send "Error!" "File specified not exists.";
+    if [ "${DESKTOP_SESSION}" != "" ]; then
+        notify-send "Error!" "File specified not exists.";
+    else
+        echo "Error! File specified not exists.";
+    fi
 fi