"Your kindle needs repair" after running ./run.sh manually

"Your kindle needs repair" after running ./run.sh manually

From: Simon Garrelou
Original thread: https://github.com/simsor/kindle-doom/issues/1
Original report by "kennedn"

---

Hi,

First of all, great project!

I ran in to a bit of an issue earlier today after running ./run.sh
manually and thought it may be worth documenting how I fixed it and
maybe providing some script considerations for run.sh to prevent it from
happening to anyone else.

I ran `run.sh` manually today via an ssh session and later `ctrl + c`'ed
the script when I was done running doom. I knew due to the `ctrl + c`
that `/etc/init.d/framework start` would have never ran, so I invoked
that manually too. My kindle then went into a framework restart loop and
eventually entered an unclean state where even after subsequent reboots,
I was presented with the dreaded "Your kindle needs repair" message.

I still had ssh access though and was able to step through a run of
`/etc/init.d/framework start` to find out that the repair message was
being displayed on the back of the contents of
`/var/local/system/.framework_reboots` being `>= 2`.

I was able to exit the repair screen by removing this file and
rebooting, I think setting the contents to a number less than 2 would
have also worked.

So as for the script, I have done a bit of debugging and it appears you
have windows line endings in run.sh inside your releases (not in the
actual repo itself):

```
#!/bin/sh^M
^M
/etc/init.d/framework stop^M
/usr/bin/lipc-set-prop -- com.lab126.powerd preventScreenSaver 1^M
./prboom -iwad /mnt/us/doom.wad -file /mnt/us/prboom.wad -nosound
-nomusic -nosfx -warp 1 1^M
/usr/bin/lipc-set-prop -- com.lab126.powerd preventScreenSaver 0^M
/etc/init.d/framework start     ^M
```

This causes the last argument of most lines in the script to be
invalidated, so in the case of `/etc/init.d/framework stop^M`, this
prevents execution:

```
+ /etc/init.d/framework stop
system: W framework:def:Usage: /etc/init.d/framework
{startx|start|stop|reset|restart|force-reload}
```

So in my case, the repair issue was actually user error. As I assumed
that the framework was in a stopped state and attempted to start it,
causing problems. However due to those line endings the only command
that actually works in run.sh is probably the `./prboom` command at
present. So probably worth fixing this.

Cheers,