#!/bin/bash

df -h|grep ' /$'|grep -o '^/cow' > /dev/null
if [ $? -ne 0 ]
then
 tmp="you should run $0 only in persistent live Ubuntu systems"
 which xmessage
 if [ $? -eq 0 ]
 then
  xmessage -center "$tmp"
 else
  echo "$tmp"
 fi
 exit
fi

if [ "$(whoami)" != "root" ]
then
 tmp="you must run $0 with sudo or as root"
 which xmessage
 if [ $? -eq 0 ]
 then
  xmessage -center "$tmp"
 else
  echo "$tmp"
 fi
 exit
fi

if ! test -s /lib/systemd/system/apparmor.service.d/30_live_mode.conf
then
 mkdir -p /lib/systemd/system/apparmor.service.d
 echo '[Unit]
ConditionPathExists=' \
 > /lib/systemd/system/apparmor.service.d/30_live_mode.conf
 tmp="Now Firefox should work in your persistent live system after reboot"
 which xmessage
 if [ $? -eq 0 ]
 then
  xmessage -center "$tmp"
 else
  echo "$tmp"
  read -p "Press Enter to finish"
 fi
fi
