Borner
Posts: 49
Joined: Tue Sep 25, 2012 2:53 pm
Location: .de

raspi-config command line parameter

Tue Oct 30, 2012 7:27 pm

Hi,

is there a way to use the raspi-config utility in an non-interactive mode? For example with command line parameters to set / enable some parameters.
I like to use the raspi-config in installation scripts.

:-)

Borner

Joe Schmoe
Posts: 4277
Joined: Sun Jan 15, 2012 1:11 pm

Re: raspi-config command line parameter

Tue Oct 30, 2012 7:40 pm

Borner wrote:Hi,

is there a way to use the raspi-config utility in an non-interactive mode? For example with command line parameters to set / enable some parameters.
I like to use the raspi-config in installation scripts.

:-)

Borner
1) "raspi-config" is a shell script, so it is inspectable. I took a brief look through, and found...

2) It looks like there is some effort to making it command-line-drivable, but it didn't actually get implemented (yet). Take a look at the script (at the end) and you'll see what I mean.

3) If you really wanted to, you could probably drive it with Expect. That's what I always do in these sorts of situations.
And some folks need to stop being fanboys and see the forest behind the trees.

(One of the best lines I've seen on this board lately)

bredman
Posts: 1415
Joined: Tue Jan 17, 2012 2:38 pm

Re: raspi-config command line parameter

Tue Oct 30, 2012 7:41 pm

Short answer: no this is not possible.

Long answer: raspi-config is just a script, so you can examine what it does when an option is selected. You can copy the relevant instructions into your installation script.

bamartin125
Posts: 1
Joined: Wed Apr 05, 2017 2:29 am

Re: raspi-config command line parameter

Wed Apr 05, 2017 2:46 am

I realize this is an old thread, but I wanted to share my recent success with calling particular routines out of raspi-config from the command line.

Essentially, I found that I could source the raspi-config script like so:

Code: Select all

$ . raspi-config nonint
The 'nonint' argument there tells the script to run in non-interactive mode which looks like it allows the script to define all of its internal functions, but not actually run anything.

At this point, I can then call functions from inside the script. For example, to enable i2c I can run:

Code: Select all

$ do_i2c 0

User avatar
RichardBronosky
Posts: 82
Joined: Thu Feb 14, 2013 5:38 pm
Location: Atlanta, GA, USA

Re: raspi-config command line parameter

Thu May 11, 2017 2:21 am

This is still not documented anywhere, but the rc_gui tool (I'm assuming it would be a graphical user interface to the raspi-config if I were to ever install the full desktop) uses command line options to the raspi-config bash script. You can see the full list of options in the C source code https://github.com/raspberrypi-ui/rc_gu ... .c#L23-L70

Code: Select all

/* Command strings */
#define GET_CAN_EXPAND  "sudo raspi-config nonint get_can_expand"
#define EXPAND_FS       "sudo raspi-config nonint do_expand_rootfs"
#define GET_HOSTNAME    "sudo raspi-config nonint get_hostname"
#define SET_HOSTNAME    "sudo raspi-config nonint do_hostname %s"
#define GET_BOOT_CLI    "sudo raspi-config nonint get_boot_cli"
#define GET_AUTOLOGIN   "sudo raspi-config nonint get_autologin"
#define SET_BOOT_CLI    "sudo raspi-config nonint do_boot_behaviour B1"
#define SET_BOOT_CLIA   "sudo raspi-config nonint do_boot_behaviour B2"
#define SET_BOOT_GUI    "sudo raspi-config nonint do_boot_behaviour B3"
#define SET_BOOT_GUIA   "sudo raspi-config nonint do_boot_behaviour B4"
#define GET_BOOT_WAIT   "sudo raspi-config nonint get_boot_wait"
#define SET_BOOT_WAIT   "sudo raspi-config nonint do_boot_wait %d"
#define GET_SPLASH      "sudo raspi-config nonint get_boot_splash"
#define SET_SPLASH      "sudo raspi-config nonint do_boot_splash %d"
#define GET_OVERSCAN    "sudo raspi-config nonint get_overscan"
#define SET_OVERSCAN    "sudo raspi-config nonint do_overscan %d"
#define GET_CAMERA      "sudo raspi-config nonint get_camera"
#define SET_CAMERA      "sudo raspi-config nonint do_camera %d"
#define GET_SSH         "sudo raspi-config nonint get_ssh"
#define SET_SSH         "sudo raspi-config nonint do_ssh %d"
#define GET_VNC         "sudo raspi-config nonint get_vnc"
#define SET_VNC         "sudo raspi-config nonint do_vnc %d"
#define GET_SPI         "sudo raspi-config nonint get_spi"
#define SET_SPI         "sudo raspi-config nonint do_spi %d"
#define GET_I2C         "sudo raspi-config nonint get_i2c"
#define SET_I2C         "sudo raspi-config nonint do_i2c %d"
#define GET_SERIAL      "sudo raspi-config nonint get_serial"
#define GET_SERIALHW    "sudo raspi-config nonint get_serial_hw"
#define SET_SERIAL      "sudo raspi-config nonint do_serial %d"
#define GET_1WIRE       "sudo raspi-config nonint get_onewire"
#define SET_1WIRE       "sudo raspi-config nonint do_onewire %d"
#define GET_RGPIO       "sudo raspi-config nonint get_rgpio"
#define SET_RGPIO       "sudo raspi-config nonint do_rgpio %d"
#define GET_PI_TYPE     "sudo raspi-config nonint get_pi_type"
#define GET_OVERCLOCK   "sudo raspi-config nonint get_config_var arm_freq /boot/config.txt"
#define SET_OVERCLOCK   "sudo raspi-config nonint do_overclock %s"
#define GET_GPU_MEM     "sudo raspi-config nonint get_config_var gpu_mem /boot/config.txt"
#define GET_GPU_MEM_256 "sudo raspi-config nonint get_config_var gpu_mem_256 /boot/config.txt"
#define GET_GPU_MEM_512 "sudo raspi-config nonint get_config_var gpu_mem_512 /boot/config.txt"
#define GET_GPU_MEM_1K  "sudo raspi-config nonint get_config_var gpu_mem_1024 /boot/config.txt"
#define SET_GPU_MEM     "sudo raspi-config nonint do_memory_split %d"
#define GET_HDMI_GROUP  "sudo raspi-config nonint get_config_var hdmi_group /boot/config.txt"
#define GET_HDMI_MODE   "sudo raspi-config nonint get_config_var hdmi_mode /boot/config.txt"
#define SET_HDMI_GP_MOD "sudo raspi-config nonint do_resolution %d %d"
#define GET_WIFI_CTRY   "sudo raspi-config nonint get_wifi_country"
#define SET_WIFI_CTRY   "sudo raspi-config nonint do_wifi_country %s"
#define CHANGE_PASSWD   "(echo \"%s\" ; echo \"%s\" ; echo \"%s\") | passwd"
-- Bruno Bronosky
1x RPi 1 (B)
1x RPi 1+ (B)
2x RPi 2
11x RPi 3
4x RPi Zero W
2x RPi camera module
3x AIY Voice kits
https://github.com/RichardBronosky/pi-gen-extender
https://github.com/RichardBronosky/raspbian-boot-setup

mrmuu
Posts: 1
Joined: Fri Aug 02, 2019 9:13 am

Re: raspi-config command line parameter

Fri Aug 02, 2019 9:16 am

Thank you very much @RichardBronosky!

this is realy usefull for automating Image builds :D

Return to “General discussion”