scotty101
Posts: 4364
Joined: Fri Jun 08, 2012 6:03 pm

Re-enable Raspi-config on next boot

Tue Mar 10, 2015 9:27 am

Is it possible to re-enable raspi-config for the next boot?

I've found the bash function "disable_raspi_config_at_boot()" inside raspi-config which seems to delete a bash script. Is this bash script stored somewhere else so I can restore it?
Also there is a sed command, can I just reverse this to re-enable raspi-config for the next boot?
Electronic and Computer Engineer
Pi Interests: Home Automation, IOT, Python and Tkinter

User avatar
DougieLawson
Posts: 41961
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: Re-enable Raspi-config on next boot

Tue Mar 10, 2015 9:58 am

Here's the stuff that's in the Raspbian filesystem before the first boot.

/etc/profile.d/raspi-config.sh

Code: Select all

#!/bin/sh
# Part of raspi-config http://github.com/asb/raspi-config
#
# See LICENSE file for copyright and license details

# Should be installed to /etc/profile.d/raspi-config.sh to force raspi-config
# to run at initial login

# You may also want to set automatic login in /etc/inittab on tty1 by adding a
# line such as:
# 1:2345:respawn:/bin/login -f root tty1 </dev/tty1 >/dev/tty1 2>&1 # RPICFG_TO_DISABLE

if [ $(id -u) -ne 0 ]; then
  printf "\nNOTICE: the software on this Raspberry Pi has not been fully configured. Please run 'sudo raspi-config'\n\n"
else
  raspi-config
  exec login -f pi
fi
/etc/inittab @ line 54

Code: Select all

#1:2345:respawn:/sbin/getty --noclear 38400 tty1 # RPICFG_TO_ENABLE
1:2345:respawn:/bin/login -f root tty1 </dev/tty1 >/dev/tty1 2>&1 # RPICFG_TO_DISABLE
Languages using left-hand whitespace for syntax are ridiculous

DMs sent on Twitter/LinkedIn will be answered next month.
Fake doctors - are all on my foes list.

The use of crystal balls and mind reading is prohibited.

W. H. Heydt
Posts: 15556
Joined: Fri Mar 09, 2012 7:36 pm
Location: Vallejo, CA (US)

Re: Re-enable Raspi-config on next boot

Tue Mar 10, 2015 10:36 pm

Do you specifically need raspi-config to pop up on the next boot, or do you just want to run raspi-config next time you boot that Pi? I ask because you can run raspi-config whenever you want. just use the command "sudo raspi-config".

scotty101
Posts: 4364
Joined: Fri Jun 08, 2012 6:03 pm

Re: Re-enable Raspi-config on next boot

Wed Mar 11, 2015 8:04 am

I'm well aware that I can just run raspi-config at any time.

My obscure use case is for creating an image to copy around a few SD cards. I'd like to keep a minimal image size on the disk whilst I am customising it then clone the image and copy to other SD cards. When each of them are plugged in they should act as if it was their first boot.

Dougie, thank you very much for the information. That gives me exactly what I need.
Electronic and Computer Engineer
Pi Interests: Home Automation, IOT, Python and Tkinter

User avatar
expandables
Posts: 654
Joined: Fri Jun 27, 2014 7:34 pm
Location: Neverland with Michael Jackson

Re: Re-enable Raspi-config on next boot

Wed Mar 11, 2015 1:28 pm

Hi i create a script that if this log file that the script creates is not in /var/log then press the enter button to start raspi-config.

You can call this script firstboot

Code: Select all

sudo nano firstboot
Then put this in the script

Code: Select all

#!/bin/bash

boot="/var/log/firstboot-startup.log"
if [ ! -f $boot ]; then
   echo ""
   echo ""
   echo "This is the first boot." 
   echo "Running raspi-config. Please expand your file system and change any other settings you need to."
   echo "After you are done. DO NOT reboot from raspi-config. Just select FINISH or NO if it ask you to reboot. That way this script can finish running."
   echo "It will  create a log to stop this script from looping and reboot afterwords."
   read -p "Press the [Enter] key to start raspi-config."
   sudo raspi-config
   #the next line creates an empty file so it won't run the next boot
   sudo touch $boot
   sudo reboot
else
  startx
fi
Then put the script in .bashrc

Code: Select all

sudo nano .bashrc

Code: Select all

./firstboot
By thinking like an engineer you can create a raspberry pi.
Michael Jackson enthusiast.
I got the PI model B, B+ and PI 2 model B.
When will I get the A? I don't know.

Return to “Advanced users”