TeslaDashcamWeb
TeslaDashcamWeb copied to clipboard
Tmp after reboot.
Ich habe Problem beim installieren. Ich hänge momentan beim nginx Webserver. Dieser startet nach einem Neustart nicht mehr. Weil ihm das tmp Verzeichnis fehlt. Was kann ich dagegen tun?
You need to add a few lines to /etc/rc.local
, before the line exit 0
:
LOGFILE=/tmp/rc.local.log
function log () {
echo -n "$( date )" >> "$LOGFILE"
echo -n ": " >> "$LOGFILE"
echo "$1" >> "$LOGFILE"
}
log "Running fsck..."
/sbin/fsck /mnt/cam -- -a >> "$LOGFILE" 2>&1 || echo ""
log "Running modprobe..."
/sbin/modprobe g_mass_storage >> "$LOGFILE" 2>&1
log "Preparing temp files..."
/bin/cp /root/.config/rclone/rclone.conf /tmp/rclone.conf >> "$LOGFILE" 2>&1
/bin/chmod 644 /tmp/rclone.conf >> "$LOGFILE" 2>&1
/bin/mkdir /var/log/nginx >> "$LOGFILE" 2>&1
/bin/mkdir -p /tmp/php/sessions >> "$LOGFILE" 2>&1
/bin/chown www-data:pi /tmp/php/sessions >> "$LOGFILE" 2>&1
/bin/mkdir -p /tmp/log/nginx >> "$LOGFILE" 2>&1
log "Starting nginx..."
/usr/sbin/service nginx start >> "$LOGFILE" 2>&1
log "All done"
This should create the tmp directories needed, and start the nginx server.
ich habe es eingfügt. Sieht so aus:
_IP=$(hostname
-I) || true
if [ "$_IP" ]; then
printf "My IP address is %s\n" "$_IP"
fi
function log () { echo -n "$( date )" >> "$LOGFILE" echo -n ": " >> "$LOGFILE" echo "$1" >> "$LOGFILE" }
log "Running fsck..." /sbin/fsck /mnt/cam -- -a >> "$LOGFILE" 2>&1 || echo "" log "Running modprobe..." /sbin/modprobe g_mass_storage >> "$LOGFILE" 2>&1 log "Preparing temp files..." /bin/cp /root/.config/rclone/rclone.conf /tmp/rclone.conf >> "$LOGFILE" 2>&1 /bin/chmod 644 /tmp/rclone.conf >> "$LOGFILE" 2>&1 /bin/mkdir /var/log/nginx >> "$LOGFILE" 2>&1 /bin/mkdir -p /tmp/php/sessions >> "$LOGFILE" 2>&1 /bin/chown www-data:pi /tmp/php/sessions >> "$LOGFILE" 2>&1 /bin/mkdir -p /tmp/log/nginx >> "$LOGFILE" 2>&1 log "Starting nginx..." /usr/sbin/service nginx start >> "$LOGFILE" 2>&1 log "All done"
exit 0 `
Funktioniert leider nicht.
/etc/rc.local: 20: /etc/rc.local: Syntax error: "(" unexpected
You are missing an important line:
LOGFILE=/tmp/rc.local.log
This must be present before the line function log() {
Sorry, ist mit drin. Geht trotzdem nicht.
Apr 25 19:08:04 raspberrypi systemd[1]: Starting A high performance web server and a reverse proxy s Apr 25 19:08:06 raspberrypi nginx[441]: nginx: [emerg] open() "/tmp/log/nginx/access.log" failed (2: Apr 25 19:08:06 raspberrypi nginx[441]: nginx: configuration file /etc/nginx/nginx.conf test failed Apr 25 19:08:06 raspberrypi systemd[1]: nginx.service: Control process exited, code=exited status=1 Apr 25 19:08:06 raspberrypi systemd[1]: Failed to start A high performance web server and a reverse Apr 25 19:08:06 raspberrypi systemd[1]: nginx.service: Unit entered failed state. Apr 25 19:08:06 raspberrypi systemd[1]: nginx.service: Failed with result 'exit-code'.
Please change this line in the /etc/rc.local, it has a bug:
/bin/mkdir -p /var/log/nginx >> "$LOGFILE" 2>&1
The -p
is necessary.
no, same problem again:
pi@raspberrypi:~ $ sudo service nginx status ● nginx.service - A high performance web server and a reverse proxy server Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled) Active: failed (Result: exit-code) since Thu 2019-04-25 19:26:59 BST; 1min 4s ago Docs: man:nginx(8) Process: 445 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, sta
Apr 25 19:26:57 raspberrypi systemd[1]: Starting A high performance web server and a reverse proxy s Apr 25 19:26:59 raspberrypi nginx[445]: nginx: [emerg] open() "/tmp/log/nginx/access.log" failed (2: Apr 25 19:26:59 raspberrypi nginx[445]: nginx: configuration file /etc/nginx/nginx.conf test failed Apr 25 19:26:59 raspberrypi systemd[1]: nginx.service: Control process exited, code=exited status=1 Apr 25 19:26:59 raspberrypi systemd[1]: Failed to start A high performance web server and a reverse Apr 25 19:26:59 raspberrypi systemd[1]: nginx.service: Unit entered failed state. Apr 25 19:26:59 raspberrypi systemd[1]: nginx.service: Failed with result 'exit-code'.
after this "mkdir -p /tmp/log/nginx" and a nginx restart it is okay
but next reboot same problem
Great! I have fixed the instructions so people don't run into this problem in future.
but next reboot same problem
Oh no. On next reboot, can you check /tmp/rc.local.log contents, and see whether /tmp/log/nginx exists?
no files in /tmp
only systemd-private-ae6960e35cf04b44a67cedaa0b9c4c79-systemd-timesyncd.service-n0GncL
can you upload a sd image? I dont get any further
I will try to capture a clean SD image. But it will take me a while to get to it.
Can you do cat /etc/rc.local
and post the full result here? If you have the correct content on there, I don't understand where there is nothing in /tmp besides that systemd file.
pi@raspberrypi:~ $ cat /etc/rc.local LOGFILE=/tmp/rc.local.log
function log () { echo -n "$( date )" >> "$LOGFILE" echo -n ": " >> "$LOGFILE" echo "$1" >> "$LOGFILE" }
log "Running fsck..." /sbin/fsck /mnt/cam -- -a >> "$LOGFILE" 2>&1 || echo "" log "Running modprobe..." /sbin/modprobe g_mass_storage >> "$LOGFILE" 2>&1 log "Preparing temp files..." /bin/cp /root/.config/rclone/rclone.conf /tmp/rclone.conf >> "$LOGFILE" 2>&1 /bin/chmod 644 /tmp/rclone.conf >> "$LOGFILE" 2>&1 /bin/mkdir -p /var/log/nginx >> "$LOGFILE" 2>&1 /bin/mkdir -p /tmp/php/sessions >> "$LOGFILE" 2>&1 /bin/chown www-data:pi /tmp/php/sessions >> "$LOGFILE" 2>&1 /bin/mkdir -p /tmp/log/nginx >> "$LOGFILE" 2>&1 log "Starting nginx..." /usr/sbin/service nginx start >> "$LOGFILE" 2>&1 log "All done" exit 0
image would be great. It would be perfect with the adjustment to 2019.8.5
I think it is not working for you because it is missing this line at the top of the /etc/rc.local file:
#!/bin/bash -e
It is OK to delete all the following lines in the original /etc/rc.local until you come to my code with LOGFILE=...
, but that first line is necessary. Can you try adding the first line at the top of the file and rebooting?
For reference, here is my full file:
#!/bin/bash -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.
# Print the IP address
_IP=$(hostname -I) || true
if [ "$_IP" ]; then
printf "My IP address is %s\n" "$_IP"
fi
LOGFILE=/tmp/rc.local.log
function log () {
echo -n "$( date )" >> "$LOGFILE"
echo -n ": " >> "$LOGFILE"
echo "$1" >> "$LOGFILE"
}
log "Running fsck..."
/sbin/fsck /mnt/cam -- -a >> "$LOGFILE" 2>&1 || echo ""
log "Running modprobe..."
/sbin/modprobe g_mass_storage >> "$LOGFILE" 2>&1
log "Preparing temp files..."
/bin/cp /root/.config/rclone/rclone.conf /tmp/rclone.conf >> "$LOGFILE" 2>&1
/bin/chmod 644 /tmp/rclone.conf >> "$LOGFILE" 2>&1
/bin/mkdir /var/log/nginx >> "$LOGFILE" 2>&1
/bin/mkdir -p /tmp/php/sessions >> "$LOGFILE" 2>&1
/bin/chown www-data:pi /tmp/php/sessions >> "$LOGFILE" 2>&1
/bin/mkdir -p /tmp/log/nginx >> "$LOGFILE" 2>&1
log "Starting nginx..."
/usr/sbin/service nginx start >> "$LOGFILE" 2>&1
log "All done"
exit 0
okay, only in last test the file was reduced
pi@raspberrypi:~ $ cat /etc/rc.local #!/bin/bash -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.
Print the IP address
_IP=$(hostname -I) || true if [ "$_IP" ]; then printf "My IP address is %s\n" "$_IP" fi
LOGFILE=/tmp/rc.local.log
function log () { echo -n "$( date )" >> "$LOGFILE" echo -n ": " >> "$LOGFILE" echo "$1" >> "$LOGFILE" }
log "Running fsck..." /sbin/fsck /mnt/cam -- -a >> "$LOGFILE" 2>&1 || echo "" log "Running modprobe..." /sbin/modprobe g_mass_storage >> "$LOGFILE" 2>&1 log "Preparing temp files..." /bin/cp /root/.config/rclone/rclone.conf /tmp/rclone.conf >> "$LOGFILE" 2>&1 /bin/chmod 644 /tmp/rclone.conf >> "$LOGFILE" 2>&1 /bin/mkdir /var/log/nginx >> "$LOGFILE" 2>&1 /bin/mkdir -p /tmp/php/sessions >> "$LOGFILE" 2>&1 /bin/chown www-data:pi /tmp/php/sessions >> "$LOGFILE" 2>&1 /bin/mkdir -p /tmp/log/nginx >> "$LOGFILE" 2>&1 log "Starting nginx..." /usr/sbin/service nginx start >> "$LOGFILE" 2>&1 log "All done"
exit 0
Are you now seeing the rc.local.log file and directories for log/nginx and php/sessions within /tmp?
no
That is strange. Did you do sudo apt update
and sudo apt upgrade
when building the pi?
Please check permissions with ls -l /etc/rc.local
. it should be -rwxr-xr-x or similar. If you see '-' instead of 'x' there, try sudo chmod +x /etc/rc.local
, confirm with the same ls command, and then reboot.
pi@raspberrypi:~ $ ls -l /etc/rc.local -rwxr-xr-x 1 root root 1161 Apr 25 20:42 /etc/rc.local
yes update && upgrade
Another test you can run... At the top of rc.local, after the first line, add a new line echo "running rc.local" > /tmp/test.log
, save and reboot. After boot is done, check /tmp to see if this new file is there.
yes, test.log and rc.local.log with this:
Thu 25 Apr 21:36:26 BST 2019: Running fsck... fsck from util-linux 2.29.2 fsck.ext2: No such file or directory while trying to open /mnt/cam Possibly non-existent device? Thu 25 Apr 21:36:26 BST 2019: Running modprobe... Thu 25 Apr 21:36:26 BST 2019: Preparing temp files... /bin/cp: cannot stat '/root/.config/rclone/rclone.conf': No such file or directory
Looks like your setup is incomplete. Did you finish all the steps from the readme?
Yes, I had already tried in previous attempts. Unfortunately, it has never worked after a reboot. That's why I first tried to fix the error now.
I tried to figure out a way to share an SD card image. But I don't know to make an SD card image where you will be able to change the WiFi settings before booting up the Pi so it works on your network. Let me know if you know a way to do this, I will keep looking in the meanwhile.