Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Combined tty + web camera + docs #29

Open
wants to merge 25 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
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
25 changes: 24 additions & 1 deletion .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,38 @@
image: gitlab/dind

stages:
- docs
- publish

variables:
VERSION: ${CI_COMMIT_REF_NAME}
CI_JOB: ${CI_JOB_ID}

before_script:
- apt-get update && apt-get install -y --no-install-recommends make linux-image-generic

job:
sd-image:
stage: publish
script:
- make sd-image
artifacts:
paths:
- hypriotos-rpi-${VERSION}.img.zip
- hypriotos-rpi-${VERSION}.img.zip.sha256

pages:
stage: docs
image: node:8.9
before_script:
- npm install gitbook-cli -g # install gitbook
- gitbook fetch latest # fetch latest stable version
- gitbook install docs # add any requested plugins in book.json
script:
- gitbook build docs builder/files/var/www/docs # build to public path
after_script:
- cp -ar builder/files/var/www/docs public
artifacts:
paths:
- public
# only:
# - master
1 change: 1 addition & 0 deletions builder/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ mount -t sysfs none ${BUILD_PATH}/sys

# modify/add image files directly
cp -R /builder/files/* ${BUILD_PATH}/
cp -R /builder/scripts/* ${BUILD_PATH}/usr/local/bin/

# make our build directory the current root
# and install the Rasberry Pi firmware, kernel packages,
Expand Down
19 changes: 19 additions & 0 deletions builder/chroot-script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,12 @@ apt-get -o Dpkg::Options::=--force-confdef \
pi-bluetooth \
lsb-release \
gettext \
unzip \
zip \
libav-tools \
gstreamer1.0-tools \
motion \
gpac \
cloud-init


Expand Down Expand Up @@ -205,10 +211,23 @@ lighttpd-enable-mod fastcgi-php
systemctl disable dhcpcd
systemctl disable hciuart

echo "Installing ttyd web terminal"
wget -q https://github.com/tsl0922/ttyd/releases/download/1.4.2/ttyd_linux.armhf -O usr/local/bin/ttyd
chmod +x usr/local/bin/ttyd
systemctl enable ttyd

echo "Installing rpi-serial-console script"
wget -q https://raw.githubusercontent.com/lurch/rpi-serial-console/master/rpi-serial-console -O usr/local/bin/rpi-serial-console
chmod +x usr/local/bin/rpi-serial-console

echo "Installing RPi Cam Web Interface"
wget -q https://github.com/silvanmelchior/RPi_Cam_Web_Interface/archive/master.zip -O /tmp/rpicam.zip
cd /tmp/
unzip rpicam.zip
cd RPi_Cam_Web_Interface-master
cp /etc/rpicam_config.txt config.txt
bash ./install.sh q

# fix eth0 interface name
ln -s /dev/null /etc/systemd/network/99-default.link

Expand Down
14 changes: 14 additions & 0 deletions builder/files/etc/rc.local
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.

exit 0
8 changes: 8 additions & 0 deletions builder/files/etc/rpicam_config.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
rpicamdir="cam"
webserver=""
webport="80"
user=""
webpasswd=""
autostart="yes"
jpglink="no"
phpversion="7"
8 changes: 8 additions & 0 deletions builder/files/etc/systemd/system/ttyd.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[Unit]
Description=ttyd Web Terminal

[Service]
ExecStart=/usr/local/bin/ttyd login

[Install]
WantedBy=multi-user.target
12 changes: 11 additions & 1 deletion builder/files/var/www/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,22 @@

<p><img src="/images/publiclab.svg" /></p>

<h2>Public Lab Pi Camera Kit</h2>
<h2>Public Lab Pi Kit</h2>

<br />

<p><i>You've correctly connected to your Pi!</i></p>
<p>If you're seeing this in a pop-up, close it and open <a href="http://pi.local">http://pi.local</a> in a browser.</p>

<p>
<a href="/cam">RPi Cam Web Interface</a>
</p>
<p>
<a href="http://pi.local:7681/">Access command line</a>
</p>
<p>
<a href="/docs">Documentation</a>
</p>

</body>
</html>
5 changes: 5 additions & 0 deletions builder/scripts/timelapse.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
while true
do
echo 'im' >> /var/www/cam/FIFO
sleep 5
done
1 change: 1 addition & 0 deletions docs/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
* [Image Builder](README.md)
* [Customization](customization.md)
* [Workflow](workflow.md)
* [Scripting](scripting.md)
* [Roadmap](roadmap.md)
30 changes: 30 additions & 0 deletions docs/scripting.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Scripting

The operating system installed is Raspbian Lite, a derivative of the popular Debian GNU/Linux distribution. Please refer to the Debian documentation for most configuration needs. *This section attempts to introduce basic recipes to make use of scripts*.

You'll need to access the terminal emulator in order to execute scripts (or schedule them). You may access the console with a SSH client or from the web terminal (if available). You may also copy files from and into the device with an SFTP client (such as `scp`).

# Writing scripts

Scripts can be written in any language included with Raspbian. The default shell is called **bash** and it's common among GNU/Linux systems.

In Debian, you may place custom scripts in the `/usr/local/bin` directory. This will make it available to all users.
Scripts should have execution privileges enabled. Execution privileges are granted with the `chmod a+x script.sh` (where `script.sh` is the script file).

**Tip**: If you are trying to run a script located in the current directory, you'll need to call it like this: `./my_script.sh` (with "./" to indicate the current directory)

# Running scripts on startup

Once your scripts are properly installed in the `/usr/local/bin` directory and work as intended, you may want to start them at boot time. You may do so by adding a line to `/etc/rc.local` which is run at the end of the boot process.

# Scheduling scripts to be run at intervals

It's possible to use the Cron daemon to schedule tasks either from root or as a user. Use the command `crontab -e` to edit the current users's cron entry. The basic syntax for a cron entry is:

`minute hour day-of-month month day-of-week user command`

Refer to the Cron manual for details (`man cron`).

# Running a script every few seconds

Try the `watch` command. It works as `watch -n seconds command` and runs a given command repeatedly and continually.
2 changes: 1 addition & 1 deletion docs/workflow.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ These images are referred to as build artifacts and are available for download d

## Flash your image

Using your preferred method (or the [Hypriot flash tool](https://github.com/hypriot/flash) which offers some flash-time customization hooks.
Using your preferred method (or the [Hypriot flash tool](https://github.com/hypriot/flash), which offers some flash-time customization hooks.

## Share your results!

Expand Down