Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion files/services/S50usb_camera-single
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ case "$1" in
start)
echo "Starting USB Camera..."
V4L_DEVS=$(v4l2-ctl --list-devices | grep -A1 usb | sed 's/^[[:space:]]*//g' | grep '^/dev')
CREALITY_CAMS=$(v4l2-ctl --list-devices | grep -E 'CREALITY|CCX2F3298' | wc -l)
CREALITY_CAMS=$(v4l2-ctl --list-devices | grep -E 'CREALITY|CCX2F329[89]' | wc -l)
if [ "x$V4L_DEVS" = "x" -o $CREALITY_CAMS -gt 0 ]; then
echo "Error: No third party camera found or you use a Creality camera!"
exit 1
Expand Down
42 changes: 42 additions & 0 deletions files/services/S59mjpg_streamer
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/bin/sh
# Internal Camera Service
# Credit: laffsj & Guilouz

BIN=/usr/bin/mjpg_streamer
PLUGINS=/usr/lib/mjpg-streamer

case "$1" in
start)
echo "Starting Internal Camera..."
if [ ! -f "$PLUGINS/input_memfd.so" ]; then
echo "Error: input_memfd.so not found, your firmware is too old for this service!"
exit 1
fi
# cam_app owns the camera and publishes frames over memfd. Wait for it in a
# backgrounded subshell so a slow camera init does not stall the boot.
(
COUNT=0
while ! pidof cam_app >/dev/null && [ "$COUNT" -lt 60 ]; do
sleep 1
COUNT=$((COUNT + 1))
done
sleep 5
pidof mjpg_streamer >/dev/null && exit 0
$BIN -b -i "$PLUGINS/input_memfd.so -t 0" -o "$PLUGINS/output_http.so -p 8080"
) &
;;
stop)
echo "Stopping Internal Camera..."
killall -q mjpg_streamer
;;
restart|reload)
"$0" stop
sleep 1
"$0" start
;;
*)
echo "Usage: /etc/init.d/S59mjpg_streamer {start|stop|restart}"
exit 1
esac

exit $?
64 changes: 64 additions & 0 deletions scripts/internal_camera.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
#!/bin/sh

set -e

function internal_camera_message(){
top_line
title 'Internal Camera Support' "${yellow}"
inner_line
hr
echo -e " │ ${cyan}This restores the internal camera stream in Mainsail and ${white}│"
echo -e " │ ${cyan}Fluidd on firmware 1.3.5.x and newer, where the camera is ${white}│"
echo -e " │ ${cyan}only reachable through cam_app. ${white}│"
hr
bottom_line
}

function install_internal_camera(){
internal_camera_message
local yn
while true; do
install_msg "Internal Camera Support" yn
case "${yn}" in
Y|y)
echo -e "${white}"
echo -e "Info: Copying file..."
cp "$INTERNAL_CAMERA_URL" "$INITD_FOLDER"/S59mjpg_streamer
chmod 755 "$INITD_FOLDER"/S59mjpg_streamer
echo -e "Info: Starting service..."
"$INITD_FOLDER"/S59mjpg_streamer start
ok_msg "Internal Camera Support has been installed successfully!"
echo -e " If the stream stays empty, add a webcam in your interface's settings"
echo -e " using ${cyan}/webcam/?action=stream${white} as stream URL."
return;;
N|n)
error_msg "Installation canceled!"
return;;
*)
error_msg "Please select a correct choice!";;
esac
done
}

function remove_internal_camera(){
internal_camera_message
local yn
while true; do
remove_msg "Internal Camera Support" yn
case "${yn}" in
Y|y)
echo -e "${white}"
echo -e "Info: Stopping service..."
"$INITD_FOLDER"/S59mjpg_streamer stop
echo -e "Info: Removing file..."
rm -f "$INITD_FOLDER"/S59mjpg_streamer
ok_msg "Internal Camera Support has been removed successfully!"
return;;
N|n)
error_msg "Deletion canceled!"
return;;
*)
error_msg "Please select a correct choice!";;
esac
done
}
1 change: 1 addition & 0 deletions scripts/menu/K1/info_menu_K1.sh
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ function info_menu_ui_k1() {
info_line "$(check_file_k1 "$TIMELAPSE_FILE")" 'Moonraker Timelapse'
info_line "$(check_file_k1 "$CAMERA_SETTINGS_FILE")" 'Camera Settings Control'
info_line "$(check_file_k1 "$USB_CAMERA_FILE")" 'USB Camera Support'
info_line "$(check_file_k1 "$INTERNAL_CAMERA_FILE")" 'Internal Camera Support'
hr
subtitle '•REMOTE ACCESS:'
info_line "$(check_folder_k1 "$OCTOEVERYWHERE_FOLDER")" 'OctoEverywhere'
Expand Down
33 changes: 22 additions & 11 deletions scripts/menu/K1/install_menu_K1.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,15 @@ function install_menu_ui_k1() {
menu_option '16' 'Install' 'Moonraker Timelapse'
menu_option '17' 'Install' 'Camera Settings Control'
menu_option '18' 'Install' 'USB Camera Support'
menu_option '19' 'Install' 'Internal Camera Support'
hr
subtitle '•REMOTE ACCESS:'
menu_option '19' 'Install' 'OctoEverywhere'
menu_option '20' 'Install' 'Moonraker Obico'
menu_option '21' 'Install' 'GuppyFLO'
menu_option '22' 'Install' 'Mobileraker Companion'
menu_option '23' 'Install' 'OctoApp Companion'
menu_option '24' 'Install' 'SimplyPrint'
menu_option '20' 'Install' 'OctoEverywhere'
menu_option '21' 'Install' 'Moonraker Obico'
menu_option '22' 'Install' 'GuppyFLO'
menu_option '23' 'Install' 'Mobileraker Companion'
menu_option '24' 'Install' 'OctoApp Companion'
menu_option '25' 'Install' 'SimplyPrint'
hr
inner_line
hr
Expand Down Expand Up @@ -190,6 +191,16 @@ function install_menu_k1() {
run "install_usb_camera" "install_menu_ui_k1"
fi;;
19)
if [ -f "$INTERNAL_CAMERA_FILE" ]; then
error_msg "Internal Camera Support is already installed!"
elif [ -f "$USB_CAMERA_FILE" ]; then
error_msg "USB Camera Support is installed, both use port 8080!"
elif [ ! -f /usr/lib/mjpg-streamer/input_memfd.so ]; then
error_msg "This requires firmware 1.3.5.x or newer!"
else
run "install_internal_camera" "install_menu_ui_k1"
fi;;
20)
if [ ! -d "$MOONRAKER_FOLDER" ]; then
error_msg "Moonraker and Nginx are needed, please install them first!"
elif [ ! -d "$FLUIDD_FOLDER" ] && [ ! -d "$MAINSAIL_FOLDER" ]; then
Expand All @@ -199,7 +210,7 @@ function install_menu_k1() {
else
run "install_octoeverywhere" "install_menu_ui_k1"
fi;;
20)
21)
if [ ! -d "$MOONRAKER_FOLDER" ]; then
error_msg "Moonraker and Nginx are needed, please install them first!"
elif [ ! -d "$FLUIDD_FOLDER" ] && [ ! -d "$MAINSAIL_FOLDER" ]; then
Expand All @@ -209,13 +220,13 @@ function install_menu_k1() {
else
run "install_moonraker_obico" "install_menu_ui_k1"
fi;;
21)
22)
if [ ! -d "$MOONRAKER_FOLDER" ] && [ ! -d "$NGINX_FOLDER" ]; then
error_msg "Moonraker and Nginx are needed, please install them first!"
else
run "install_guppyflo" "install_menu_ui_k1"
fi;;
22)
23)
if [ -d "$MOBILERAKER_COMPANION_FOLDER" ]; then
error_msg "Mobileraker Companion is already installed!"
elif [ ! -d "$MOONRAKER_FOLDER" ]; then
Expand All @@ -227,7 +238,7 @@ function install_menu_k1() {
else
run "install_mobileraker_companion" "install_menu_ui_k1"
fi;;
23)
24)
if [ -d "$OCTOAPP_COMPANION_FOLDER" ]; then
error_msg "OctoApp Companion is already installed!"
elif [ ! -d "$MOONRAKER_FOLDER" ]; then
Expand All @@ -239,7 +250,7 @@ function install_menu_k1() {
else
run "install_octoapp_companion" "install_menu_ui_k1"
fi;;
24)
25)
if grep -q "\[simplyprint\]" "$MOONRAKER_CFG"; then
error_msg "SimplyPrint is already installed!"
elif [ ! -d "$MOONRAKER_FOLDER" ]; then
Expand Down
29 changes: 18 additions & 11 deletions scripts/menu/K1/remove_menu_K1.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,15 @@ function remove_menu_ui_k1() {
menu_option '16' 'Remove' 'Moonraker Timelapse'
menu_option '17' 'Remove' 'Camera Settings Control'
menu_option '18' 'Remove' 'USB Camera Support'
menu_option '19' 'Remove' 'Internal Camera Support'
hr
subtitle '•REMOTE ACCESS:'
menu_option '19' 'Remove' 'OctoEverywhere'
menu_option '20' 'Remove' 'Moonraker Obico'
menu_option '21' 'Remove' 'GuppyFLO'
menu_option '22' 'Remove' 'Mobileraker Companion'
menu_option '23' 'Remove' 'OctoApp Companion'
menu_option '24' 'Remove' 'SimplyPrint'
menu_option '20' 'Remove' 'OctoEverywhere'
menu_option '21' 'Remove' 'Moonraker Obico'
menu_option '22' 'Remove' 'GuppyFLO'
menu_option '23' 'Remove' 'Mobileraker Companion'
menu_option '24' 'Remove' 'OctoApp Companion'
menu_option '25' 'Remove' 'SimplyPrint'
hr
inner_line
hr
Expand Down Expand Up @@ -198,36 +199,42 @@ function remove_menu_k1() {
run "remove_usb_camera" "remove_menu_ui_k1"
fi;;
19)
if [ ! -f "$INTERNAL_CAMERA_FILE" ]; then
error_msg "Internal Camera Support is not installed!"
else
run "remove_internal_camera" "remove_menu_ui_k1"
fi;;
20)
if [ ! -d "$OCTOEVERYWHERE_FOLDER" ]; then
error_msg "OctoEverywhere is not installed!"
else
run "remove_octoeverywhere" "remove_menu_ui_k1"
fi;;
20)
21)
if [ ! -d "$MOONRAKER_OBICO_FOLDER" ]; then
error_msg "Moonraker Obico is not installed!"
else
run "remove_moonraker_obico" "remove_menu_ui_k1"
fi;;
21)
22)
if [ ! -d "$GUPPYFLO_FOLDER" ]; then
error_msg "GuppyFLO is not installed!"
else
run "remove_guppyflo" "remove_menu_ui_k1"
fi;;
22)
23)
if [ ! -d "$MOBILERAKER_COMPANION_FOLDER" ]; then
error_msg "Mobileraker Companion is not installed!"
else
run "remove_mobileraker_companion" "remove_menu_ui_k1"
fi;;
23)
24)
if [ ! -d "$OCTOAPP_COMPANION_FOLDER" ]; then
error_msg "OctoApp Companion is not installed!"
else
run "remove_octoapp_companion" "remove_menu_ui_k1"
fi;;
24)
25)
if ! grep -q "\[simplyprint\]" "$MOONRAKER_CFG"; then
error_msg "SimplyPrint is not installed!"
else
Expand Down
4 changes: 4 additions & 0 deletions scripts/paths.sh
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,10 @@ function set_paths() {
USB_CAMERA_SINGLE_URL="${HS_FILES}/services/S50usb_camera-single"
USB_CAMERA_DUAL_URL="${HS_FILES}/services/S50usb_camera-dual"

# Internal Camera Support
INTERNAL_CAMERA_FILE="${INITD_FOLDER}/S59mjpg_streamer"
INTERNAL_CAMERA_URL="${HS_FILES}/services/S59mjpg_streamer"

# OctoEverywhere #
OCTOEVERYWHERE_FOLDER="${USR_DATA}/octoeverywhere"
OCTOEVERYWHERE_URL="https://github.com/QuinnDamerell/OctoPrint-OctoEverywhere.git"
Expand Down