INSTALL 1.91 KB
Newer Older
1
#!/bin/bash
Edvard Rejthar's avatar
Edvard Rejthar committed
2 3 4 5
# Installation file for MDMaug
# If environment variable LC_ALL is empty, you may have some troubles with setting system locale as I had.

DESTINATION=/opt/mdmaug
6 7
PROFILE_COUNT=21

Edvard Rejthar's avatar
Edvard Rejthar committed
8 9 10 11
# sometimes, there is no repository with pip on the machine, trying to add some sources
apt install software-properties-common
add-apt-repository "deb http://archive.ubuntu.com/ubuntu $(lsb_release -sc) main universe restricted multiverse"
apt update
12
apt install firefox python3 mariadb-server xvfb
13 14
pip3 install xvfbwrapper pymysql peewee jinja2 pyyaml bs4 pygments pillow requests

15 16 17 18
# current dir
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd $DIR

19
# mariadb setup
20 21
systemctl start mariadb.service
mysql -u root < mdmaug-installation.sql # populate db
22
mysql -uroot -e "CREATE USER \"mdmaug\"@\"localhost\" IDENTIFIED BY \"fidFDSs676\"; GRANT ALL PRIVILEGES ON mdmaug. * TO \"mdmaug\"@\"localhost\";" # new user
23 24 25 26 27 28 29 30 31 32 33 34 35 36

# adding user the server will be run under
useradd -m -d $DESTINATION mdmaug

# copy all important files
cp -r mdmaug $DESTINATION
cp -r .mozilla $DESTINATION
cp *.md $DESTINATION
cd $DESTINATION

# copy firefox profiles (about:config is stored at prefs.js file)
for(( i=1; i<=$((PROFILE_COUNT-1)); i++ )) 
do
    DEST=$DESTINATION/.mozilla/firefox/$i/
37 38 39 40 41
    if [ -d $DEST ]; then
        echo "profile $i already exists, wont change" 
    else
        cp -R .mozilla/firefox/0 $DEST
    fi
42 43
done 

44
# adopt all files to the new user
45
chown mdmaug:mdmaug -R $DESTINATION
46

47
# make the new user able to use the display (needed on Ubuntu 17.10 at least; after every restart :( not sure what to do)
48
xhost +local:mdmaug
49 50 51

# Writer from Firefox to the disk
echo "{\"name\": \"firefox_mdmaug_writer\", \"description\": \"Firefox disk writer\", \"path\": \"$DESTINATION/mdmaug/bin/firefox_mdmaug_writer.py\", \"type\": \"stdio\", \"allowed_extensions\": [ \"mdmaug@csirt.cz\" ] }" > $DESTINATION/.mozilla/native-messaging-hosts/firefox_mdmaug_writer.json
Edvard Rejthar's avatar
Edvard Rejthar committed
52