Advertisement
Guest User

Untitled

a guest
Sep 8th, 2017
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 2.39 KB | None | 0 0
  1. #!/bin/bash
  2. #wordpress connection settings
  3. USER="wordpress"
  4. PASSWORD="password"
  5. HOST="mysql.mysite.com"
  6. DB="wordpress"
  7. MYSQL="/usr/bin/mysql"
  8.  
  9. #remove current relationship for headline/post, set random post as headline
  10. HEADLINE0="DELETE FROM wp_term_relationships WHERE term_taxonomy_id='103'; INSERT INTO wp_term_relationships (object_id,term_taxonomy_id,term_order) VALUES ((select ID from wp_posts where post_name NOT LIKE '%autosave%' AND post_name != '' and post_name !='hello-world' AND ID !='2' AND ID !='16' AND ID !='35' AND ID !='44' ORDER BY RAND() LIMIT 1),'103','0');"
  11.  
  12. #select current headline post - for reference, we never use this in the script
  13. HEADLINE1="select * from wp_term_relationships where term_taxonomy_id = '103';"
  14.  
  15. #remove current relationship for featured/post, set random post as featured
  16. FEATURED0="DELETE FROM wp_term_relationships WHERE term_taxonomy_id='104'; INSERT INTO wp_term_relationships (object_id,term_taxonomy_id,term_order) VALUES
  17. ((select ID from wp_posts where post_name NOT LIKE '%autosave%' AND post_name != '' and post_name !='hello-world' AND ID !='2' AND ID !='16' AND ID !='35' AND ID !='44' ORDER BY RAND() LIMIT 1),'104','0'),
  18. ((select ID from wp_posts where post_name NOT LIKE '%autosave%' AND post_name != '' and post_name !='hello-world' AND ID !='2' AND ID !='16' AND ID !='35' AND ID !='44' ORDER BY RAND() LIMIT 1),'104','0'),
  19. ((select ID from wp_posts where post_name NOT LIKE '%autosave%' AND post_name != '' and post_name !='hello-world' AND ID !='2' AND ID !='16' AND ID !='35' AND ID !='44' ORDER BY RAND() LIMIT 1),'104','0'),
  20. ((select ID from wp_posts where post_name NOT LIKE '%autosave%' AND post_name != '' and post_name !='hello-world' AND ID !='2' AND ID !='16' AND ID !='35' AND ID !='44' ORDER BY RAND() LIMIT 1),'104','0'),
  21. ((select ID from wp_posts where post_name NOT LIKE '%autosave%' AND post_name != '' and post_name !='hello-world' AND ID !='2' AND
  22. ID !='16' AND ID !='35' AND ID !='44' ORDER BY RAND() LIMIT 1),'104','0');"
  23.  
  24. #execute queries
  25. echo -n "Updating headline: "
  26. until $MYSQL --user="$USER" --password="$PASSWORD" --host="$HOST" "$DB" -e "$HEADLINE0"; do
  27.     echo "[FAILED]"
  28.     echo -n "Running again: "
  29. done
  30.  
  31. echo "[OK]"
  32.  
  33. echo -n "Updating featured: "
  34. until $MYSQL --user="$USER" --password="$PASSWORD" --host="$HOST" "$DB" -e "$FEATURED0"; do
  35. echo "[FAILED]"
  36.     echo -n "Running again: "
  37. done
  38.  
  39. echo "[OK]"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement