|
| 1 | +set -x |
| 2 | +set -e |
| 3 | + |
| 4 | +export LC_ALL=C |
| 5 | + |
| 6 | +source /common.sh |
| 7 | +install_cleanup_trap |
| 8 | + |
| 9 | +# no need to install if we already have it |
| 10 | +[ -f "/opt/mjpg-streamer/input_libcamera.so" ] && exit 0 |
| 11 | + |
| 12 | +install_dir=/opt/mjpg-streamer |
| 13 | +[ -d $install_dir ] && rm -rf $install_dir |
| 14 | +apt-get install --yes libcamera-dev libjpeg-dev cmake libboost-program-options-dev libdrm-dev libexif-dev |
| 15 | + |
| 16 | +cd /home/pi |
| 17 | + |
| 18 | +curl -L -o mjpg-streamer-master.zip https://github.com/ArduCAM/mjpg-streamer/archive/refs/heads/master.zip |
| 19 | +unzip mjpg-streamer-master.zip |
| 20 | +rm mjpg-streamer-master.zip |
| 21 | + |
| 22 | +pushd mjpg-streamer-master/mjpg-streamer-experimental |
| 23 | + build_dir=_build |
| 24 | + mkdir -p $build_dir |
| 25 | + pushd $build_dir |
| 26 | + cmake -DCMAKE_BUILD_TYPE=Release .. |
| 27 | + popd |
| 28 | + |
| 29 | + make -j $(nproc) -C $build_dir |
| 30 | + |
| 31 | + mkdir -p $install_dir |
| 32 | + |
| 33 | + install -m 755 $build_dir/mjpg_streamer $install_dir |
| 34 | + find $build_dir -name "*.so" -type f -exec install -m 644 {} $install_dir \; |
| 35 | + |
| 36 | + # copy bundled web folder |
| 37 | + cp -a -r ./www $install_dir |
| 38 | + chmod 755 $install_dir/www |
| 39 | + chmod -R 644 $install_dir/www |
| 40 | + |
| 41 | + # create our custom web folder and add a minimal index.html to it |
| 42 | + mkdir $install_dir/www-octopi |
| 43 | + pushd $install_dir/www-octopi |
| 44 | + cat <<EOT >> index.html |
| 45 | +<html> |
| 46 | +<head><title>mjpg_streamer test page</title></head> |
| 47 | +<body> |
| 48 | +<h1>Snapshot</h1> |
| 49 | +<p>Refresh the page to refresh the snapshot</p> |
| 50 | +<img src="./?action=snapshot" alt="Snapshot"> |
| 51 | +<h1>Stream</h1> |
| 52 | +<img src="./?action=stream" alt="Stream"> |
| 53 | +</body> |
| 54 | +</html> |
| 55 | +EOT |
| 56 | + popd |
| 57 | +popd |
| 58 | + |
| 59 | +rm -rf mjpg-streamer-master |
0 commit comments