Skip to content

Instantly share code, notes, and snippets.

@CyberLine
Created Sep 20, 2012
Embed
What would you like to do?
Synology Diskstation DAViCal Installation Script
#!/bin/sh
# check for bootstrap installation
if [ !$(which ipkg) ]; then
echo "ipkg not found. Please install bootstrap package first!";
echo "See: http://forum.synology.com/wiki/index.php/How_to_Install_Bootstrap";
exit;
fi;
# install system tools and second postgres
ipkg install perl perl-dbi make sed postgresql binutils busybox optware-devel
# patch postgres config for non conflicting if not exists
if [ "0" == $(egrep '^port = 5433$' /opt/var/pgsql/data/postgresql.conf | wc -l) ]; then
echo "port = 5433" >> /opt/var/pgsql/data/postgresql.conf
fi;
# install needed host entrys for davical
if [ "0" == $(grep davical /opt/var/pgsql/data/pg_hba.conf | wc -l) ]; then
echo -a "local davical davical_app trust\nlocal davical davical_dba trust" >> /opt/var/pgsql/data/pg_hba.conf
fi;
# start the installed postgres cluster
/opt/etc/init.d/S98postgresql start
# install needed perl packaged
cpan -fi CPAN YAML
# build the perl package for davical installation
mkdir -p /usr/local/etc/davical
wget http://search.cpan.org/CPAN/authors/id/T/TU/TURNSTEP/DBD-Pg-2.19.3.tar.gz -O - | tar -xz -C /usr/local
cd /usr/local/DBD-Pg-2.19.3 && perl Makefile.PL LD=/opt/bin/ld && make && make install
# install vhost file for davical if not exists
if [ ! -e "/opt/etc/apache2/conf.d/davical.vhost" ]; then
( cat << "EOCODE"
begin 644 -
M3&ES=&5N(#@P,#@*/%9I<G1U86Q(;W-T("HZ.#`P.#X*("`@("`@("!$;V-U
M;65N=%)O;W0@+V]P="]S:&%R92]D879I8V%L+VAT9&]C<PH@("`@("`@($1I
M<F5C=&]R>4EN9&5X(&EN9&5X+G!H<"`*("`@("`@("!!;&EA<R`O:6UA9V5S
M+R`O;W!T+W-H87)E+V1A=FEC86PO:'1D;V-S+VEM86=E<R\*("`@("`@("`\
M1&ER96-T;W)Y("]O<'0O<VAA<F4O9&%V:6-A;"]H=&1O8W,O/B`@(`H@("`@
M("`@("`@("`@("`@06QL;W=/=F5R<FED92!.;VYE"B`@("`@("`@/"]$:7)E
M8W1O<GD^"B`@("`@("`@<&AP7W9A;'5E(&EN8VQU9&5?<&%T:"`B+CHO;W!T
M+W-H87)E+V%W;"]I;F,B"B`@("`@("`@<&AP7W9A;'5E(&5R<F]R7W)E<&]R
M=&EN9R`B15]!3$P@)B!^15].3U1)0T4B"B`@("`@("`@<&AP7W9A;'5E(&1E
E9F%U;'1?8VAA<G-E="`B=71F+3@B"CPO5FER='5A;$AO<W0^"@``
`
end
EOCODE
) | uudecode -o- >> /opt/etc/apache2/conf.d/davical.vhost
fi;
# check for needed open_basedir modification
if [ "0" == "$(grep /opt/share/davical /usr/syno/etc/php/user-setting.ini | wc -l)" ]; then
sed -i -e 's/^open_basedir = .*/&:\/opt\/share\/davical:\/opt\/share\/awl\/inc:\/usr\/local\/etc\/davical/' /usr/syno/etc/php/user-setting.ini;
fi;
# append davical.vhost to the user apache if not exists
if [ "0" == $(egrep '^Include /opt/etc/apache2/conf.d/davical.vhost' /usr/syno/apache/conf/httpd.conf-user | wc -l) ]; then
echo "Include /opt/etc/apache2/conf.d/davical.vhost" >> /usr/syno/apache/conf/httpd.conf-user
fi;
#restart the user apache
/usr/syno/etc.defaults/rc.d/S97apache-user.sh restart
# install davical if not exists
if [ ! -e "/opt/share/davical" ]; then
wget http://debian.mcmillan.net.nz/packages/davical/davical-1.1.1.tar.gz -O - | tar -xz -C /opt/share/
mv /opt/share/davical-1.1.1/ /opt/share/davical/
else
echo "davical installation exists. nothing to do."
fi;
# install needed "awl" if not exists
if [ ! -e "/opt/share/awl/" ]; then
wget http://debian.mcmillan.net.nz/packages/awl/awl-0.53.tar.gz -O - | tar -xz -C /opt/share/
mv /opt/share/awl-0.53/ /opt/share/awl/
else
echo "awl installation exists. nothing to do.";
fi;
# install davical database if not exists
if [ "0" == $(psql -p 5433 -l template1 postgres | grep davical | wc -l) ]; then
PGPORT=5433 PGUSER=postgres /opt/share/davical/dba/create-database.sh
fi;
# copy sample config files for each interface if not exists
for ADDR in $(ip -4 addr list | grep inet | awk '{print $2}' | awk -F '/' '{print $1}'); do
if [ ! -e "/usr/local/etc/davical/$ADDR-conf.php" ]; then
cp /opt/share/davical/config/example-config.php /usr/local/etc/davical/$ADDR-conf.php
fi;
done;
echo -e "Installation done!\nPoint your browser to your diskstation IP port 8008 and complete DAViCal setup.";
@mikael35

This comment has been minimized.

Copy link

@mikael35 mikael35 commented Feb 9, 2014

Report incorrect status about ipkg which is correctly installed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment