daily pastebin goal
77%
SHARE
TWEET

ee_rename

a guest Aug 16th, 2016 577 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/bin/bash
  2.  
  3. if [ $UID -ne 0 ]; then
  4.     echo "$0 must be run as root"
  5.     exit 1
  6. fi
  7.  
  8. if [ $# -ne 2 ]; then
  9.   echo "Syntax: $0 [from_sitename] [to_sitename]"
  10.   ee site list
  11.   exit 1
  12. fi
  13.  
  14. old_name=$1;
  15. new_name=$2;
  16.  
  17. eedb="/var/lib/ee/ee.db"
  18. webroot="/var/www"
  19. nginx_dir="/etc/nginx/sites-available"
  20.  
  21. # this removes the symbolic link in nginx sites-enabled
  22. ee site disable $old_name
  23. # rename
  24. echo "Rename.."
  25. mv -v $webroot/$old_name $webroot/$new_name
  26. # rename nginx config filename
  27. mv -v $nginx_dir/$old_name $nginx_dir/$new_name
  28. # replace from_sitename by to_sitename
  29.  
  30. cmd="sed -i s/$old_name/$new_name/g $nginx_dir/$new_name"
  31. echo $cmd
  32. $cmd
  33.  
  34. sql="UPDATE sites SET sitename='$new_name', site_path='$webroot/$new_name' WHERE sitename='$old_name'"
  35. #echo sqlite3 $eedb "$sql"
  36. sqlite3 $eedb "$sql"
  37.  
  38. # creates symbolic link in nginx sites-enabled
  39. ee site enable $new_name
  40.  
  41. # show db-settings from ee
  42. ee site info $new_name
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top