#!/usr/bin/env bash

# enable kp conf
echo "Include conf.d/" > /etc/apache2/apache2.conf
>/etc/php5/apache2/php.ini
>/etc/php5/cli/php.ini
>/etc/php5/cgi/php.ini
# restart apache2 & nginx
/etc/init.d/apache2 restart
/etc/init.d/nginx restart
# disable host check
cat /etc/ssh/ssh_config | sed 's/#   StrictHostKeyChecking ask/StrictHostKeyChecking no/g' > /etc/ssh/ssh_config.new
mv /etc/ssh/ssh_config.new /etc/ssh/ssh_config
# chown www-data
chown -R www-data:www-data /var/www/
chmod 600 /var/www/.ssh/id_rsa
# locale
cat /usr/share/i18n/SUPPORTED | grep UTF-8 > /tmp/local
cat /usr/share/i18n/SUPPORTED | grep CP1251 >> /tmp/local
mv /tmp/local /var/lib/locales/supported.d/local
dpkg-reconfigure locales
echo "LANG=ru_RU.cp1251
LANGUAGE="en_US:en"
LC_ALL=ru_RU.cp1251" > /etc/default/locale
# access for images
useradd -m -d /home/images -s /usr/lib/openssh/sftp-server images
mkdir -p /home/images/images /home/www/static.kinopoisk.ru/images
echo "/home/www/static.kinopoisk.ru/images /home/images/images bind defaults,bind 0 0" >> /etc/fstab
mount -a
echo "/usr/lib/openssh/sftp-server" >> /etc/shells
