#!/bin/bash

export PATH=/usr/sbin:/sbin:$PATH

is_active=$(</sys/class/leds/gpio-flash/brightness)

FILE=/tmp/flashlight_on

if [ "$is_active" = "1" ]
then
    echo '1' > "$FILE"
    if [ "$1" = "pre" ]
    then 
	touch "$FILE"
	echo '0' > /sys/class/leds/gpio-flash/brightness
    fi
fi

if test -f "$FILE"
then
    if [ "$1" = "post" ]
    then
	echo '1' > /sys/class/leds/gpio-flash/brightness
	rm "$FILE"
    fi 
fi
