Paste #200

  • #200
  1. #!/bin/bash
  2. # This script upgrades a sendy installation, retaining the configuration,
  3. # languages & uploads.
  4. #
  5. # 2015-01-24 - http://sleepanarchy.com
  6.  
  7. if [ $# -ne 2 ]; then
  8.     echo "Usage: sendy_upgrade.sh <upgrade zip file> <install folder>"
  9.     echo ""
  10.     echo "    sendy_upgrade.sh ~/sendy-2.0.1.zip ~/public_html/sendy"
  11.     exit
  12. fi
  13.  
  14. SENDY_PACKAGE="$1"
  15. SENDY_INSTALL_DIR="$2"
  16.  
  17. # Unzip the package
  18. UNZIP_DIR="$HOME/sendy"
  19. TEMP_SENDY_DIR="$UNZIP_DIR/sendy"
  20. mkdir -p $UNZIP_DIR
  21. unzip $SENDY_PACKAGE -d $UNZIP_DIR
  22.  
  23. # Remove files we will replace
  24. rm -rf $TEMP_SENDY_DIR/includes/config.php $TEMP_SENDY_DIR/.htaccess \
  25.        $TEMP_SENDY_DIR/uploads $TEMP_SENDY_DIR/locale/en_US
  26.  
  27. # Copy over files from old installation
  28. cp $SENDY_INSTALL_DIR/includes/config.php $TEMP_SENDY_DIR/includes/
  29. cp $SENDY_INSTALL_DIR/.htaccess $TEMP_SENDY_DIR/
  30. cp -r $SENDY_INSTALL_DIR/uploads $SENDY_INSTALL_DIR/locale $TEMP_SENDY_DIR
  31.  
  32. # Backup & Replace the old installation
  33. CURRENT_TIME="`date +%s`"
  34. BACKUP_DIR="$HOME/sendy_backup_$CURRENT_TIME/"
  35. mkdir -p $BACKUP_DIR
  36. mv $SENDY_INSTALL_DIR $BACKUP_DIR
  37. mv $TEMP_SENDY_DIR $SENDY_INSTALL_DIR
  38.  
  39. rm -rf $UNZIP_DIR
  40.  
  41. echo "Upgrade Complete!"

Reply to this snippet →

Top Languages

Python 2385
Text 73
Code 72
Haskell 36
Java 35
HTML 19
Bash 14
PHP 9
Diff 7
INI 5