bygdis.fi

git clone https://git.tarina.org/bygdis.fi
Log | Files | Refs | README

install.sh (2680B)


      1 #!/bin/bash
      2 
      3 ROOT_UID=0   # Root has $UID 0.
      4 
      5 if [ "$UID" -eq "$ROOT_UID" ]
      6 then
      7    echo "OK"
      8 else
      9     echo "Run with sudo!"
     10     echo "sudo ./install.sh"
     11     exit 0
     12 fi
     13 
     14 echo "Hurray! du e sudo user!"
     15 cat <<'EOF'
     16 
     17       .__---~~~(~~-_.
     18    _-'  ) -~~- ) _-" )_
     19   (  ( `-,_..`.,_--_ '_,)_
     20  (  -_)  ( -_-~  -_ `,    )
     21  (_ -_ _-~-__-~`, ,' )__-'))--___--~~~--__--~~--___--__..
     22  _ ~`_-'( (____;--==,,_))))--___--~~~--__--~~--__----~~~'`=__-~+_-_.
     23 (@) (@) `````      `-_(())_-~  mn
     24 EOF
     25 
     26 echo "Installing all dependencies..."
     27 apt-get update
     28 sudo apt install apache2 libapache2-mod-wsgi-py3 python3-pip python3-pil python3-bcrypt
     29 python3 -m pip install web.py==0.61
     30 
     31 echo "skapar databasen..."
     32 cd db
     33 ./makedb.sh
     34 cd ..
     35 
     36 echo "default username and passcode"
     37 cp hemligt.py.sample hemligt.py
     38 
     39 echo "skapa www-data åtkomst"
     40 mkdir sessions
     41 sudo chown -R www-data sessions
     42 sudo chown -R www-data db
     43 sudo chown -R www-data public_html/static/bilder
     44 
     45 DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
     46 ACONF="/etc/apache2/sites-available/bygdis.conf"
     47 
     48 echo "Adding local site to /etc/apache2/sites-available/bygdis.conf"
     49 cat <<'EOF' > $ACONF
     50 <VirtualHost *:80>
     51     ServerName localhost
     52 EOF
     53 echo "    DocumentRoot $DIR" >> $ACONF
     54 echo "    WSGIScriptAlias / $DIR/server.py" >> $ACONF
     55 echo "    WSGIPassAuthorization On" >> $ACONF
     56 echo "    AddType text/html .py" >> $ACONF
     57 echo "    Alias /static $DIR/public_html/static" >> $ACONF
     58 echo "    <Directory $DIR/public_html>" >> $ACONF
     59 cat <<'EOF' >> $ACONF
     60         Options FollowSymlinks
     61 	AllowOverride None
     62 	Require all granted
     63     </Directory>
     64     ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
     65     <Directory "/usr/lib/cgi-bin">
     66         AllowOverride None
     67         Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
     68         Require all granted
     69     </Directory>
     70 EOF
     71 echo "    ErrorLog $DIR/error.log" >> $ACONF
     72 echo "</VirtualHost>" >> $ACONF
     73 
     74 echo "<Directory $DIR>" >> /etc/apache2/apache2.conf
     75 cat <<'EOF' >> /etc/apache2/apache2.conf
     76 	Options Indexes FollowSymLinks
     77 	AllowOverride None
     78 	Require all granted
     79 </Directory>
     80 EOF
     81 
     82 sudo a2ensite bygdis.conf
     83 sudo systemctl restart apache2
     84 
     85 cat <<'EOF'
     86                        .-.
     87         .-""`""-.    |(@ @)
     88      _/`oOoOoOoOo`\_ \ \-/
     89     '.-=-=-=-=-=-=-.' \/ \
     90       `-=.=-.-=.=-'    \ /\
     91          ^  ^  ^       _H_ \
     92 
     93 alrite, du kan nu skriva in "localhost" i webläsarn. bygdis.fi siidona borde va up-n-running på din egen dator, nu kan du börja testa devva. skicka pull request sen ba när du ha duuna någå siistit.
     94 
     95 användarnamn: username
     96 lösenord: password
     97 
     98 du kan ändra dessa i hemligt.py
     99 
    100 ifall det inte fungerar kolla error.log, kan behövas några dependencies ännu.
    101 EOF
    102