forked from jancborchardt/nextcloud-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
owncloud-raspberrypi.sh
122 lines (86 loc) · 4.02 KB
/
owncloud-raspberrypi.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
#!/bin/bash
# Set up ownCloud on a Raspberry Pi
# Plus extras (easy access and backups)
# Making it a fully capable home server
# Some prerequisites:
# 1. Get a Raspberry Pi, including power supply, SD card and network cable
# 2. Install Raspbian on the SD card using your computer
# http://www.raspberrypi.org/documentation/installation/installing-images/README.md
# 3. Put the SD card in your Rasperry Pi, connect it to the router or your computer using the network cable and let it start up.
# 4. Use SSH to log in to the Pi from your laptop: ssh pi@raspberrypi
# http://www.raspberrypi.org/documentation/remote-access/ssh/unix.md
# Now run this script!
# 5. Use raspi-config to expand the filesystem and set a password
# http://www.raspberrypi.org/documentation/configuration/raspi-config.md
sudo raspi-config
# 6. Install Apache & PHP: http://www.raspberrypi.org/documentation/remote-access/web-server/apache.md
sudo apt-get install apache2 -y
sudo apt-get install php5 libapache2-mod-php5 -y
# 6.1 (optional instead of using SQLite)
# Install MySQL, set a password, and create a database
# http://www.raspberrypi.org/documentation/usage/wordpress/README.md
# sudo apt-get install mysql-server php5-mysql -y
# mysql -uroot -p
# In MySQL: create database owncloud; exit;
# 7. Download and set up ownCloud
# Install ownCloud from packages https://owncloud.org/install/#instructions-packages
sudo sh -c 'echo "deb http://download.opensuse.org/repositories/isv:/ownCloud:/community/Debian_7.0/ /" >> /etc/apt/sources.list.d/owncloud.list'
wget http://download.opensuse.org/repositories/isv:ownCloud:community/Debian_7.0/Release.key
sudo apt-key add - < Release.key
rm Release.key
sudo apt-get update
sudo apt-get install owncloud
echo 'Setting up APC for caching ...'
sudo apt-get install php-apc php5-dev -y
sudo pecl install apc
sudo sh -c 'echo "extension=apc.so" >> /etc/php5/cgi/conf.d/apc.ini'
sudo sh -c 'echo "apc.enabled=1" >> /etc/php5/cgi/conf.d/apc.ini'
sudo sh -c 'echo "apc.shm_size=30" >> /etc/php5/cgi/conf.d/apc.ini'
# TODO
# Further optimizations from http://www.instructables.com/id/Raspberry-Pi-Owncloud-dropbox-clone/?ALLSTEPS
# (Especially modifications to the php.ini, 000-default and .htaccess)
sudo a2enmod rewrite
sudo a2enmod headers
echo "Restarting server ..."
sudo service apache2 restart
# 8. Finish the ownCloud installation using the web interface
echo 'Now go to http://raspberrypi/owncloud and finish the installation'
echo "Choose an admin username and password, and you're done! :)"
# 9. Install PageKite to be able to access your Pi remotely with ease
# https://pagekite.net/wiki/Howto/GNULinux/DebianPackage/
echo deb http://pagekite.net/pk/deb/ pagekite main | sudo tee -a /etc/apt/sources.list
sudo apt-key adv --recv-keys --keyserver keys.gnupg.net AED248B1C7B2CAC3
sudo apt-get update
sudo apt-get install pagekite
# Configure the system https://pagekite.net/wiki/Howto/GNULinux/ConfigureYourSystem/
sudo nano /etc/pagekite.d/10_account.rc
# TODO prompt to input kite name and secret
sudo mv /etc/pagekite.d/80_httpd.rc.sample /etc/pagekite.d/80_httpd.rc
sudo mv /etc/pagekite.d/80_sshd.rc.sample /etc/pagekite.d/80_sshd.rc
sudo invoke-rc.d pagekite restart
# TODO set up SSH connection: https://pagekite.net/wiki/Howto/SshOverPageKite/
# add this to ~/.ssh/config
Host *.pagekite.me
CheckHostIP no
ProxyCommand /bin/nc -X connect -x %h:443 %h %p
# 10. Set up backups
# http://www.raspberrypi.org/documentation/linux/filesystem/backup.md
# TODO
# 11. Automatic updates
# TODO set as cronjob
sudo apt-get update && sudo apt-get upgrade -y
# 12. Configure wifi usb dongle
# http://raspberrypihq.com/how-to-add-wifi-to-the-raspberry-pi/
# TODO
# 13. Add IP address to known_hosts in ownCloud config.php
sudo nano /var/www/owncloud/config/config.php
# TODO
# 14. If you have an SSH key, add the public key to the Pi for easier log in
mkdir .ssh
cd .ssh
nano authorized_keys
#TODO: properly check if there is a key and copy it over
cd ..
chmod 700 .ssh/
chmod 600 .ssh/authorized_keys
#TODO: add ssh pi@raspberrypi to .bashrc on laptop