TeslaDashcamWeb icon indicating copy to clipboard operation
TeslaDashcamWeb copied to clipboard

Tmp after reboot.

Open Sebbo69 opened this issue 5 years ago • 50 comments

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?

Sebbo69 avatar Apr 25 '19 05:04 Sebbo69

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.

ppamidimarri avatar Apr 25 '19 15:04 ppamidimarri

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.

Sebbo69 avatar Apr 25 '19 16:04 Sebbo69

/etc/rc.local: 20: /etc/rc.local: Syntax error: "(" unexpected

Sebbo69 avatar Apr 25 '19 16:04 Sebbo69

You are missing an important line:

LOGFILE=/tmp/rc.local.log

This must be present before the line function log() {

ppamidimarri avatar Apr 25 '19 17:04 ppamidimarri

Sorry, ist mit drin. Geht trotzdem nicht.

Sebbo69 avatar Apr 25 '19 18:04 Sebbo69

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'.

Sebbo69 avatar Apr 25 '19 18:04 Sebbo69

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.

ppamidimarri avatar Apr 25 '19 18:04 ppamidimarri

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'.

Sebbo69 avatar Apr 25 '19 18:04 Sebbo69

after this "mkdir -p /tmp/log/nginx" and a nginx restart it is okay

Sebbo69 avatar Apr 25 '19 18:04 Sebbo69

but next reboot same problem

Sebbo69 avatar Apr 25 '19 18:04 Sebbo69

Great! I have fixed the instructions so people don't run into this problem in future.

ppamidimarri avatar Apr 25 '19 18:04 ppamidimarri

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?

ppamidimarri avatar Apr 25 '19 18:04 ppamidimarri

no files in /tmp

Sebbo69 avatar Apr 25 '19 18:04 Sebbo69

only systemd-private-ae6960e35cf04b44a67cedaa0b9c4c79-systemd-timesyncd.service-n0GncL

Sebbo69 avatar Apr 25 '19 18:04 Sebbo69

can you upload a sd image? I dont get any further

Sebbo69 avatar Apr 25 '19 19:04 Sebbo69

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.

ppamidimarri avatar Apr 25 '19 19:04 ppamidimarri

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

Sebbo69 avatar Apr 25 '19 19:04 Sebbo69

image would be great. It would be perfect with the adjustment to 2019.8.5

Sebbo69 avatar Apr 25 '19 19:04 Sebbo69

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

ppamidimarri avatar Apr 25 '19 19:04 ppamidimarri

okay, only in last test the file was reduced

Sebbo69 avatar Apr 25 '19 19:04 Sebbo69

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

Sebbo69 avatar Apr 25 '19 19:04 Sebbo69

Are you now seeing the rc.local.log file and directories for log/nginx and php/sessions within /tmp?

ppamidimarri avatar Apr 25 '19 20:04 ppamidimarri

no

Sebbo69 avatar Apr 25 '19 20:04 Sebbo69

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.

ppamidimarri avatar Apr 25 '19 20:04 ppamidimarri

pi@raspberrypi:~ $ ls -l /etc/rc.local -rwxr-xr-x 1 root root 1161 Apr 25 20:42 /etc/rc.local

yes update && upgrade

Sebbo69 avatar Apr 25 '19 20:04 Sebbo69

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.

ppamidimarri avatar Apr 25 '19 20:04 ppamidimarri

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

Sebbo69 avatar Apr 25 '19 20:04 Sebbo69

Looks like your setup is incomplete. Did you finish all the steps from the readme?

ppamidimarri avatar Apr 25 '19 20:04 ppamidimarri

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.

Sebbo69 avatar Apr 25 '19 20:04 Sebbo69

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.

ppamidimarri avatar Apr 26 '19 03:04 ppamidimarri