2 次代码提交 a4586de639 ... 3932d17763

作者 SHA1 备注 提交日期
  Jeff Cliff 3932d17763 some more robustness 10 月之前
  Jeff Cliff d2e3bdb6da ugh some people DO start the line with it, gotta make it more specific 10 月之前
共有 2 个文件被更改,包括 39 次插入7 次删除
  1. 1 1
      getSPCURL.sh
  2. 38 6
      howFar.sh

+ 1 - 1
getSPCURL.sh

@@ -14,7 +14,7 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <https://www.gnu.org/licenses/>.
 
-toot whois  $1  2>/dev/null | grep '^ID\:' | awk -F' ' '{print "https://shitposter.world/users/"$2}' 
+toot whois  $1  2>/dev/null | grep '^ID\: ' | awk -F' ' '{print "https://shitposter.world/users/"$2}' 
 
 # 2>&1 redirects stderr to stdout
 # if toot fails for some reason this is where to look but it's not clear that we want that happening

+ 38 - 6
howFar.sh

@@ -13,6 +13,7 @@
 #
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <https://www.gnu.org/licenses/>.
+ 
 
 TEMP=`mktemp`
 TEMP1=`mktemp`
@@ -73,7 +74,14 @@ if [[ -z $LEVEL ]]; then
 	fi
 
 	NEWLEVEL=`sqlite3 $FEDIDB -line "select level from instances where name like '"$DOMAIN"';" | grep -i 'level' | awk -F' ' '{print $3}'`
-	if [ -z $NEWLEVEL ]; then
+	HOWMANY=`how_many_arguments.sh $NEWLEVEL`
+        if [[ $HOWMANY -gt 1 ]]; then
+	    setterm --foreground red
+            echo "looks like we have too many levels: " $WHAT
+	    setterm --foreground default
+	    exit 1
+        fi
+	if [[ -z $NEWLEVEL ]]; then
 		echo "insert into news values ("$NEWID2",\""$WHAT"\",0,'','','');"
 	else
 		echo "insert into news values ("$NEWID2",\""$WHAT"\","$NEWLEVEL",'','','');"
@@ -97,6 +105,15 @@ ISCLOUDWALL=`sqlite3 $FEDIDB -line "select iscf from instances where name = \"$D
 #echo "db" $FEDIDB
 #echo "cloudwall" $ISCLOUDWALL
 # thanks https://dev.to/dak425/how-to-check-if-a-string-is-empty-in-bash-264l
+ICWA=`how_many_arguments.sh $ISCLOUDWALL`
+
+if [[ $ICWA -gt 1 ]]; then
+    setterm --foreground red
+    echo "something up with " $DOMAIN
+    setterm --foreground default
+fi
+
+echo "is cloudwall" $ISCLOUDWALL
 if [[ -z $ISCLOUDWALL  ]] ; then
     setterm --foreground red
     echo "we are probably missing " $DOMAIN " in our database"
@@ -106,7 +123,7 @@ if [[ -z $ISCLOUDWALL  ]] ; then
     setterm --foreground default
     exit;
 fi
-if [ $ISCLOUDWALL -eq 2 ] ; then 
+if [ $ISCLOUDWALL -eq 2 ] ; then
     echo $DOMAIN " was in the database but cf status not known"
     setterm --foreground yellow
     echo "CLOUDFLARE - STATUS UNKNOWN"
@@ -132,12 +149,27 @@ echo "user LEVEL is " $LEVEL
 #echo "why:"
 echo "what:" $WHAT
 
-sqlite3 $DB -line "select why from news where url = \""$WHAT"\"" | grep -i 'why' 
+# this is the line where things can go wrong if there's 2 results
+# we don't want to incur another database hit.
+WHYLINE=`sqlite3 $DB -line "select why from news where url = \""$WHAT"\"" | grep -i 'why'`
+sqlite3 $DB -line "select why from news where url = \""$WHAT"\"" | grep -i 'why' > /tmp/whylines
+WHYLINELINES=`wc -l /tmp/whylines | awk -F' ' '{print $1}'`
+
+#WHYLINELINES=`echo $WHYLINE`
+echo "WHYWLINELINES " $WHYLINELINES
+if [[ $WHYLINELINES -gt 1 ]]; then
+echo "we have more than one line!!!!" 
+setterm --foreground red
+echo "problem at $WHAT "
+setterm --foreground default
+exit
+fi
+echo $WHYLINE
+
 echo "we are over by:"
 echo "("$FEDILEVEL" - "$LEVEL")/"$MAXLEVEL
 echo "("$FEDILEVEL" - "$LEVEL")/"$MAXLEVEL   | bc;
 LEVEL2=`echo $LEVEL + "("$FEDILEVEL" - "$LEVEL")/"$MAXLEVEL | bc`
-
 LEVEL3=`echo "("$FEDILEVEL" - "$LEVEL")/"$MAXLEVEL   | bc`
 echo "level3" $LEVEL3
 if [[ -z $LEVEL3 ]]; then
@@ -145,9 +177,9 @@ if [[ -z $LEVEL3 ]]; then
 	echo "fedi level again:" $FEDILEVEL
 	echo "level again:" $LEVEL
 	echo "maxlevel again:" $MAXLEVEL
-elif [  $LEVEL3 -eq "0" ] ; then
+elif [[  $LEVEL3 -eq "0" ]] ; then
 	echo "its zero"
-else 
+else
 	echo "id" $ID
 	echo "update news set level = " $LEVEL2 " where id = "$ID";"
 	echo "WHAT Is " $WHAT