Skip to content

Instantly share code, notes, and snippets.

@l3lake
Last active August 29, 2015 14:04
Show Gist options
  • Select an option

  • Save l3lake/876ce7ec5f56948aab78 to your computer and use it in GitHub Desktop.

Select an option

Save l3lake/876ce7ec5f56948aab78 to your computer and use it in GitHub Desktop.

Revisions

  1. l3lake revised this gist Jul 29, 2014. 1 changed file with 5 additions and 6 deletions.
    11 changes: 5 additions & 6 deletions installOwncloud.sh
    Original file line number Diff line number Diff line change
    @@ -1,18 +1,17 @@
    #!/bin/bash
    #
    # Install owncloud
    # This script assumes you already have installed Apache & MySQL
    #
    # http://www.rosehosting.com/blog/script-install-owncloud-on-an-ubuntu-12-04-vps/
    #
    # Save the script above as installOwncloud.sh (if you haven’t already),
    # change “YOUR MYSQL ROOT PASSWORD” with your MySQL root password and then type the following commands:
    #
    # This script assumes you already have installed Apache & MySQL
    # Save the script as installOwncloud.sh (if you haven’t already), and
    # change “YOUR MYSQL ROOT PASSWORD” with your MySQL root password and then
    # type the following commands:
    #
    # a+x installOwncloud.sh
    # ./installOwncloud.sh your.domainname.com
    #
    # Finally, open your web browser and navigate to your ownCloud instance
    #

    # Change me
    MYSQL_ROOT_PASSWD="YOUR MYSQL ROOT PASSWORD"
  2. l3lake created this gist Jul 29, 2014.
    89 changes: 89 additions & 0 deletions installOwncloud.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,89 @@
    #!/bin/bash
    #
    # Install owncloud
    # This script assumes you already have installed Apache & MySQL
    #
    # http://www.rosehosting.com/blog/script-install-owncloud-on-an-ubuntu-12-04-vps/
    #
    # Save the script above as installOwncloud.sh (if you haven’t already),
    # change “YOUR MYSQL ROOT PASSWORD” with your MySQL root password and then type the following commands:
    #
    # a+x installOwncloud.sh
    # ./installOwncloud.sh your.domainname.com
    #
    # Finally, open your web browser and navigate to your ownCloud instance
    #

    # Change me
    MYSQL_ROOT_PASSWD="YOUR MYSQL ROOT PASSWORD"

    # Path to your localhost
    www="/var/www"

    # Apache User
    wwwdata="www-data"

    # Make sure only root can run our script
    if [ "$(id -u)" != "0" ]; then
    echo "This script must be run as root" 1>&2
    exit 1
    fi

    # Check arguments
    if [ $# -ne 1 ]; then
    echo "Usage $0 domainName"
    exit 1
    fi

    # Create MySQL database
    MYSQL_OC_PASSWD=$(</dev/urandom tr -dc A-Za-z0-9 | head -c 8)
    Q1="CREATE DATABASE IF NOT EXISTS owncloud;"
    Q2="GRANT ALL PRIVILEGES ON owncloud.* TO 'owncloud'@'localhost' IDENTIFIED BY '$MYSQL_OC_PASSWD';"
    Q3="FLUSH PRIVILEGES;"
    SQL="${Q1}${Q2}${Q3}"
    mysql -uroot -p$MYSQL_ROOT_PASSWD -e "$SQL" > /dev/null 2>&1

    # Check if the database is created
    if [ $? -ne 0 ]; then
    echo "Cannot connect to the MySQL database server"
    exit 1
    fi

    # Create the file with VirtualHost configuration
    echo "<VirtualHost *:80>
    DocumentRoot $www/owncloud
    ServerName $1
    ServerAlias $1
    <Directory $www/owncloud>
    Options Indexes FollowSymLinks MultiViews +Includes
    AllowOverride All
    Order allow,deny
    allow from all
    </Directory>
    </VirtualHost>" > /etc/apache2/sites-available/$1

    # Update System
    apt-get -y update > /dev/null 2>&1

    # Install PHP modules
    apt-get -y install php5 php5-json php-xml php-mbstring php5-zip php5-gd php5-sqlite php5-mysql curl libcurl3 libcurl3-dev php5-curl php-pdo > /dev/null 2>&1

    # Download and extract the latest version
    wget -qO- -O tmp.tar.bz2 http://owncloud.org/releases/owncloud-latest.tar.bz2 && tar -C $www -xjf tmp.tar.bz2 && rm tmp.tar.bz2

    # Set owner
    chown $www-data: -R $www/owncloud

    # Enable the site
    a2ensite $1 > /dev/null 2>&1

    # Reload Apache2
    /etc/init.d/apache2 restart > /dev/null 2>&1

    # Output
    clear
    echo "Open your web browser and navigate to your ownCloud instance"
    echo "Url: $1"
    echo "Database: owncloud"
    echo "Database user: owncloud"
    echo "Database user password: $MYSQL_OC_PASSWD"f