#!/bin/bash PANDORA=${PANDORA-pandora} POSTGRES=${POSTGRES-local} RABBITMQ=${RABBITMQ-local} NGINX=${NGINX-local} echo Installing pandora with user: $PANDORA getent passwd $PANDORA > /dev/null 2>&1 || adduser --disabled-password --gecos "" $PANDORA LXC=`grep -q lxc /proc/1/environ && echo 'yes' || echo 'no'` if [ -e /etc/os-release ]; then . /etc/os-release fi if [ -d "/run/systemd/system/" ]; then SYSTEMD="yes" else SYSTEMD="no" fi if [ -z "$UBUNTU_CODENAME" ]; then UBUNTU_CODENAME=zesty fi export DEBIAN_FRONTEND=noninteractive echo "deb http://ppa.launchpad.net/j/pandora/ubuntu ${UBUNTU_CODENAME} main" > /etc/apt/sources.list.d/j-pandora.list apt-key add - < /etc/apt/apt.conf.d/99languages apt-get update -qq if [ "$LXC" == "no" ]; then apt-get install -y \ acpid \ ntp fi EXTRA="" if [ "$POSTGRES" == "local" ]; then EXTRA="$EXTRA postgresql postgresql-contrib" fi if [ "$RABBITMQ" == "local" ]; then EXTRA="$EXTRA rabbitmq-server" fi if [ "$NGINX" == "local" ]; then EXTRA="$EXTRA nginx" fi apt-get install -y \ sudo \ openssh-server \ vim \ wget \ pwgen \ git \ python3-setuptools \ python3-pip \ virtualenv \ python3-virtualenv \ python3-dev \ python3-pil \ python3-numpy \ python3-psycopg2 \ python3-pyinotify \ python3-simplejson \ python3-lxml \ python3-html5lib \ python3-ox \ oxframe \ ffmpeg \ mkvtoolnix \ gpac \ imagemagick \ poppler-utils \ youtube-dl \ ipython3 \ postfix \ postgresql-client $EXTRA if [ "$POSTGRES" == "local" ]; then sudo -u postgres createuser -S -D -R $PANDORA sudo -u postgres createdb -T template0 --locale=C --encoding=UTF8 -O $PANDORA pandora echo "CREATE EXTENSION pg_trgm;" | sudo -u postgres psql pandora fi #rabbitmq if [ "$RABBITMQ" == "local" ]; then RABBITPWD=$(pwgen -n 16 -1) rabbitmqctl add_user pandora $RABBITPWD rabbitmqctl add_vhost /pandora rabbitmqctl set_permissions -p /pandora pandora ".*" ".*" ".*" BROKER_URL="amqp://pandora:$RABBITPWD@localhost:5672//pandora" else BROKER_URL="$RABBITMQ" fi #pandora git clone https://git.0x2620.org/pandora.git /srv/pandora cd /srv/pandora ./ctl init HOST=$(hostname -s) HOST_CONFIG="/srv/pandora/pandora/config.$HOST.jsonc" SITE_CONFIG="/srv/pandora/pandora/config.jsonc" test -e $HOST_CONFIG && cp $HOST_CONFIG $SITE_CONFIG test -e $SITE_CONFIG || cp /srv/pandora/pandora/config.pandora.jsonc $SITE_CONFIG cat > /srv/pandora/pandora/local_settings.py <> /srv/pandora/pandora/local_settings.py fi /srv/pandora/ctl start #logrotate #cp "/srv/pandora/etc/logrotate.d/pandora" "/etc/logrotate.d/pandora" #nginx if [ "$NGINX" == "local" ]; then cp "/srv/pandora/etc/nginx/pandora" "/etc/nginx/sites-available/default" read -r -d '' GZIP <> /etc/systemd/timesyncd.conf else cat > /etc/cron.d/ntp_fixtime </dev/null EOF fi cat > /usr/local/bin/genissue < /etc/issue cat > /etc/rc.local < /etc/issue EOF chmod +x /etc/rc.local fi apt-get clean cat > /home/$PANDORA/.vimrc < "+gP imap i vmap "+y filetype plugin indent on syntax on au BufNewFile,BufRead *.jsonc setf javascript nmap :tabprev nmap :tabnext hi SpellBad ctermbg=0 nnoremap :set invpaste paste? set pastetoggle= set showmode set lcs=tab:→·,trail:·,nbsp:˽ set list EOF