Skip to content

Instantly share code, notes, and snippets.

@rcguy
Last active August 29, 2015 14:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rcguy/0199ac928b0a1c9da5df to your computer and use it in GitHub Desktop.
Save rcguy/0199ac928b0a1c9da5df to your computer and use it in GitHub Desktop.
Non-Interactive Script that adds the ownCloud apt repository, installs ownCloud, then creates a MySQL user & database for it
#!/bin/bash
# Installs ownCloud and setup the MySQL Database on Ubuntu 14.10
# Tested on: Ubuntu Server 14.10 - x64 + x86 / 2 Cores / 2GB RAM / 20 GB SSD / VPS
# ==> USER VARIABLES <==
# mysql variables
MYSQL_ROOT_PASS="root"
DB_NAME="owncloud"
DB_USER="owncloud"
DB_USER_PASS="owncloud"
# ==> MAIN PROGRAM <==
set -e
# pre-seed mysql root password
echo "mysql-server-5.5 mysql-server/root_password password $MYSQL_ROOT_PASS" | sudo debconf-set-selections
echo "mysql-server-5.5 mysql-server/root_password_again password $MYSQL_ROOT_PASS" | sudo debconf-set-selections
# install ownCloud
sh -c "echo 'deb http://download.opensuse.org/repositories/isv:/ownCloud:/community/xUbuntu_14.10/ /' >> /etc/apt/sources.list.d/owncloud.list"
wget http://download.opensuse.org/repositories/isv:ownCloud:community/xUbuntu_14.10/Release.key
apt-key add - < Release.key
apt-get update
apt-get install owncloud -y
rm Release.key
# create database and user for ownCloud
MYSQL=`which mysql`
Q1="CREATE DATABASE IF NOT EXISTS $DB_NAME;"
Q2="GRANT ALL PRIVILEGES ON $DB_NAME.* TO '$DB_USER'@'localhost' IDENTIFIED BY '$DB_USER_PASS';"
Q3="FLUSH PRIVILEGES;"
SQL="${Q1}${Q2}${Q3}"
$MYSQL -uroot -p$MYSQL_ROOT_PASS -e "$SQL"
# finish
sed -i 's/;default_charset = "UTF-8"/default_charset = "UTF-8"/' /etc/php5/apache2/php.ini # set php5 to UTF-8
sh -c "echo 'User-agent: *\nDisallow: /' >> /var/www/html/robots.txt" # create robots.txt
sleep 3
service apache2 reload
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment