#!/bin/bash

DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
cd "$DIR"
cd ..
PROGRAM_NAME=`basename $PWD`
cd "$DIR"
#The following two lines allow pkexec to do a GUI-based password prompt to allow root privileges (since gksudo isn't an option anymore) when you try to do something that needs them.
sudo cp ./org.freedesktop.policykit.shule.policy /usr/share/polkit-1/actions/org.freedesktop.policykit.shule.policy
sudo cp ./org.freedesktop.python3.policy /usr/share/polkit-1/actions/org.freedesktop.python3.policy
sudo cp Shule.desktop /usr/share/applications/Shule.desktop #This puts Shule in the menu for all users.
sudo python3 ./mime_stuff.py #This associates Shule with text files and such (for all users).
if ! [[ -d "/opt/bin" ]]; then
    sudo mkdir /opt/bin
fi
if ! [[ -d "/opt/share" ]]; then
    sudo mkdir /opt/share
fi
sudo mkdir /opt/share/shule
sudo chmod -R 0777 /opt/share/shule #We want the settings to be writable by all users.
sudo cp ./shule /opt/bin/shule #This copies our script that launches Shule.
./UPDATE
#sudo chmod -R 0777 /opt/shule #This is if you want /opt/shule to be writable (and by all users)
sudo update-alternatives --install /usr/bin/shule shule /opt/bin/shule 0 #This makes it so shule is in your path. If you have another program named shule, this might cause problems.