Search code examples
ubuntuubuntu-server

Show message or run script on first login after reboot of ubuntu server


essentially I would like to make sure I mount an encrypted drive after each reboot of my ubuntu server. Since this obviously requires me to type in my password, there are two ways I can imagine this to work:

  • either show a message on each first log in of my user following a reboot (basically a reminder), or
  • automatically running a script on each first log in of my user following a reboot.

Is either of the two possible at all and/or is there another (possibly more elegant) way to achieve this?

Thanks a ton for your advice!
Best,
J

See suggestion below for the first step toward a working solution. Basically, here's what I ended up doing:

  1. write script, which checks if device is mounted and execute mounting command if not:
mount | grep -c mapper/[device mapper] # this returns 1 if mounted, 0 if not
  1. Run this as cronjob

Solution

  • You could run a script on startup via cron. Simply run crontab -e to create a cron-table. (It will create an empty one if you don't already have one.)

    To run your script on startup, use

    @reboot /home/user/script_at_reboot.sh.

    Further documentation in the ubuntu wiki.