Installing motionEye into a Fedora 26 Chroot

Below are the commands that I will be using to install motionEye into a Fedora 26 chroot

export CHROOTDIR=/opt/chroots/fedora-chroot
cd $CHROOTDIR/../
./chroot-mount.sh $CHROOTDIR
chroot $CHROOTDIR /bin/bash -l
dnf install --nogpgcheck http://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-$(rpm -E %fedora).noarch.rpm
dnf install motion ffmpeg v4l-utils python-pip python-devel gcc libcurl-devel which
pip install motioneye
mkdir -p /etc/motioneye
cp /usr/share/motioneye/extra/motioneye.conf.sample /etc/motioneye/motioneye.conf
mkdir -p /var/lib/motioneye

cat > /etc/init.d/motioneye <<"EOF"
#!/bin/bash
#
# /etc/init.d/motioneye: Start the motionEye server
# httpd        Startup script for the motionEye Server
#
# chkconfig: - 85 15
# description: The Motioneye camera viewing service  \
#              is a python program that uses Motion.
# processname: meyectl
# config: /etc/motioneye/motioneye.conf
# pidfile: /var/run/motioneye.pid
#
### BEGIN INIT INFO
# Provides:      motioneye
# Required-Start: $local_fs $syslog $remote_fs
# Required-Stop: $remote_fs
# Default-Start:  2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start the motionEye server
# Description: Start the motionEye server
### END INIT INFO

NAME="motioneye"
PATH="/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin:/usr/local/sbin"
DAEMON="meyectl"
PIDFILE="/var/run/$NAME.pid"
DESC="motionEye server"
USER="root"
OPTIONS="startserver -c /etc/motioneye/motioneye.conf -l -b"


. /etc/rc.d/init.d/functions


RET=0

case "$1" in
    start)
        echo -n $"Starting $DESC"
        daemon --pidfile=${PIDFILE} $DAEMON $OPTIONS
        RETVAL=$?
        echo
        ;;

    stop)
        echo -n $"Stopping $DESC "
        killproc -p ${PIDFILE} $DAEMON
        echo
        ;;

    restart)
        log_action_begin_msg "Restarting $DESC"
        if $0 stop && $0 start; then
            log_action_end_msg 0
        else
            log_action_cont_msg "(failed)"
            RET=1
        fi
        ;;

    status)
        printf "%-50s" "Checking $NAME..."
        if [ -f $PIDFILE ]; then
            PID=`cat $PIDFILE`
            if [ -z "`ps axf | grep ${PID} | grep -v grep`" ]; then
                printf "%s\n" "Process dead but pidfile exists"
            else
                echo "Running"
            fi
        else
            printf "%s\n" "Service not running"
        fi
        ;;

    *)
        echo "Usage: /etc/init.d/$NAME {start|stop|restart|status}"
        RET=1
        ;;
esac

exit $RET
EOF

chmod +x /etc/init.d/motioneye

/etc/init.d/motioneye start

cat >> /root/chroot-services.sh <<"EOF"

servicearray=( motioneye )

case "$1" in
  start)
        for a in "${servicearray[@]}"
        do
          /etc/init.d/$a start
        done
        ;;
  stop)
        for a in "${servicearray[@]}"
        do
          /etc/init.d/$a stop
        done
        ;;
esac
EOF