build: installer script for debian

This commit is contained in:
nachoparker 2017-11-05 15:23:49 +01:00
parent d0a839c09d
commit 9212ecb09b
3 changed files with 114 additions and 35 deletions

View File

@ -56,7 +56,7 @@ EOF
## INITIALIZE NEXTCLOUD
echo "Setting up Nextcloud..."
echo "Setting up Nextcloud... wait until message 'NC init done'"
cd /var/www/nextcloud/
rm -f config/config.php
@ -85,6 +85,8 @@ EOF
# other
sudo -u www-data php occ config:system:set overwriteprotocol --value=https
echo "NC init done"
}
install(){ :; }

77
install.sh Normal file
View File

@ -0,0 +1,77 @@
#!/bin/bash
# NextCloudPi installation script
#
# Copyleft 2017 by Ignacio Nunez Hernanz <nacho _a_t_ ownyourbits _d_o_t_ com>
# GPL licensed (see end of file) * Use at your own risk!
#
# Usage: ./install.sh
#
# more details at https://ownyourbits.com
#DBG=x
set -e$DBG
TMPDIR=/tmp/nextcloudpi
[[ ${EUID} -ne 0 ]] && {
printf "Must be run as root. Try 'sudo $0'\n"
exit 1
}
# check_distro
grep -q -e "Debian GNU/Linux 9" -e "Raspbian GNU/Linux 9" /etc/issue || {
echo "distro not supported";
exit 1;
}
# check installed software
type apache2 &>/dev/null && APACHE_EXISTS=1
type mysqld &>/dev/null && echo ">>> WARNING: existing mysqld configuration will be changed <<<"
# get install code
echo "Getting build code..."
apt-get update
apt-get install --no-install-recommends -y wget ca-certificates sudo git
rm -rf "$TMPDIR"
git clone -q --depth 1 https://github.com/nextcloud/nextcloudpi.git "$TMPDIR" || exit 1
cd "$TMPDIR"
# install NCP
echo "Installing NextCloudPi"
source etc/library.sh
install_script lamp.sh
install_script etc/nextcloudpi-config.d/nc-nextcloud.sh
activate_script etc/nextcloudpi-config.d/nc-nextcloud.sh
activate_script etc/nextcloudpi-config.d/nc-init.sh
install_script nextcloudpi.sh
# re-enable mods disabled during install, in case there's other shared services in apache2
[[ "$APACHE_EXISTS" != "" ]] && \
a2enmod status reqtimeout env autoindex access_compat auth_basic authn_file authn_core alias access_compat
# cleanup
cd -
rm -rf $TMPDIR
echo "Done. Type 'sudo nextcoludpi-config' to configure NCP"
# License
#
# This script is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This script is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this script; if not, write to the
# Free Software Foundation, Inc., 59 Temple Place, Suite 330,
# Boston, MA 02111-1307 USA

View File

@ -26,19 +26,19 @@ export DEBIAN_FRONTEND=noninteractive
install()
{
# NEXTCLOUDPI-CONFIG
##########################################
apt-get update
$APTINSTALL dialog whiptail
mkdir -p $CONFDIR
# include option in raspi-config (only Raspbian)
test -f /usr/bin/raspi-config && {
sed -i '/Change User Password/i"0 NextCloudPi Configuration" "Configuration of NextCloudPi" \\\\' /usr/bin/raspi-config
sed -i '/1\\\\ \*) do_change_pass ;;/i0\\\\ *) nextcloudpi-config ;;' /usr/bin/raspi-config
}
# NEXTCLOUDPI-CONFIG WEB
##########################################
# VIRTUAL HOST
## VIRTUAL HOST
cat > /etc/apache2/sites-available/ncp.conf <<EOF
Listen 4443
<VirtualHost _default_:4443>
@ -91,12 +91,12 @@ EOF
a2enmod authnz_external authn_core auth_basic
a2ensite ncp
# NCP USER FOR AUTHENTICATION
## NCP USER FOR AUTHENTICATION
useradd $WEBADMIN
echo -e "$WEBPASSWD\n$WEBPASSWD" | passwd $WEBADMIN
# NCP LAUNCHER
mkdir /home/www -p
## NCP LAUNCHER
mkdir -p /home/www
chown www-data:www-data /home/www
chmod 700 /home/www
@ -121,32 +121,7 @@ EOF
chmod 700 /home/www/ncp-launcher.sh
echo "www-data ALL = NOPASSWD: /home/www/ncp-launcher.sh , /sbin/halt" >> /etc/sudoers
# NEXTCLOUDPI MOTD
##########################################
rm -rf /etc/update-motd.d
mkdir /etc/update-motd.d
rm /etc/motd
ln -s /var/run/motd /etc/motd
cat > /etc/update-motd.d/10logo <<EOF
#!/bin/sh
echo
cat /usr/local/etc/ncp-ascii.txt
EOF
cat > /etc/update-motd.d/20updates <<'EOF'
#!/bin/bash
/usr/local/bin/ncp-check-updates
EOF
chmod a+x /etc/update-motd.d/*
# HOSTNAME
##########################################
echo nextcloudpi > /etc/hostname
sed -i '$c127.0.1.1 nextcloudpi' /etc/hosts
# NEXTCLOUDPI AUTO TRUSTED DOMAIN
##########################################
mkdir -p /usr/lib/systemd/system
cat > /usr/lib/systemd/system/nextcloud-domain.service <<'EOF'
[Unit]
@ -178,7 +153,6 @@ EOF
[[ "$DOCKERBUILD" != 1 ]] && systemctl enable nextcloud-domain
# NEXTCLOUDPI UPDATES
##########################################
cat > /etc/cron.daily/ncp-check-version <<EOF
#!/bin/sh
/usr/local/bin/ncp-check-version
@ -198,8 +172,34 @@ EOF
/usr/local/bin/ncp-update
# tag image
echo "NextCloudPi_$( date "+%m-%d-%y" )" > /usr/local/etc/ncp-baseimage
# ONLY FOR IMAGE BUILDS
[[ "$IMGBUILD" == 1 ]] && {
## NEXTCLOUDPI MOTD
rm -rf /etc/update-motd.d
mkdir /etc/update-motd.d
rm /etc/motd
ln -s /var/run/motd /etc/motd
cat > /etc/update-motd.d/10logo <<EOF
#!/bin/sh
echo
cat /usr/local/etc/ncp-ascii.txt
EOF
cat > /etc/update-motd.d/20updates <<'EOF'
#!/bin/bash
/usr/local/bin/ncp-check-updates
EOF
chmod a+x /etc/update-motd.d/*
## HOSTNAME
echo nextcloudpi > /etc/hostname
sed -i '$c127.0.1.1 nextcloudpi' /etc/hosts
## tag image
echo "NextCloudPi_$( date "+%m-%d-%y" )" > /usr/local/etc/ncp-baseimage
}
}
configure() { :; }