Difference between revisions of "Pidora-Headless-Mode"

From CDOT Wiki
Jump to: navigation, search
(Headless Mode Script Update)
Line 51: Line 51:
 
Initially there were a few issues with dchp and headless mode since our release the headless script has been updated. It has not been officially added to the updates repo yet but, if you are interested in trying this mode out now you can copy and replace the old headon script with the updated one located at /usr/bin/headon
 
Initially there were a few issues with dchp and headless mode since our release the headless script has been updated. It has not been officially added to the updates repo yet but, if you are interested in trying this mode out now you can copy and replace the old headon script with the updated one located at /usr/bin/headon
  
#!/bin/bash
+
#!/bin/bash
headless=`ls /boot/headless* 2> /dev/null | head -n 1`
+
headless=`ls /boot/headless* 2> /dev/null | head -n 1`
echo "Headless Mode Enabled"
+
echo "Headless Mode Enabled"
if [ -e "$headless" ]
+
if [ -e "$headless" ]
then
+
then
        systemctl enable sshd.service
+
      systemctl enable sshd.service
        systemctl start sshd.service
+
      systemctl start sshd.service
        systemctl stop firstboot-graphical.service
+
      systemctl stop firstboot-graphical.service
        systemctl disable firstboot-graphical.service
+
      systemctl disable firstboot-graphical.service
        
+
 
        headtext=`grep '[0-9]' "$headless"`
+
       headtext=`grep '[0-9]' "$headless"`
        if [ "$headtext"  != "" ]
+
      if [ "$headtext"  != "" ]
        then
+
      then
     
+
 
                ip_address=$(sed -n 's/IPADDR=//p' $headless)
+
              ip_address=$(sed -n 's/IPADDR=//p' $headless)
                ip_netmask=$(sed -n 's/NETMASK=//p' $headless)
+
              ip_netmask=$(sed -n 's/NETMASK=//p' $headless)
                ip_gateway=$(sed -n 's/GATEWAY=//p' $headless)
+
              ip_gateway=$(sed -n 's/GATEWAY=//p' $headless)
                
+
      swap_size=$(sed -n 's/SWAP=//p' $headless)
                cat << EOF > /etc/sysconfig/network-scripts/ifcfg-eth0
+
 
DEVICE=eth0
+
               cat << EOF > /etc/sysconfig/network-scripts/ifcfg-eth0
IPADDR=$ip_address
+
DEVICE=eth0
NETMASK=$ip_netmask
+
IPADDR=$ip_address
GATEWAY=$ip_gateway
+
NETMASK=$ip_netmask
BOOTPROTO=static
+
GATEWAY=$ip_gateway
ONBOOT=yes
+
BOOTPROTO=static
NM_CONTROLLED=yes
+
ONBOOT=yes
EOF
+
NM_CONTROLLED=yes
                
+
EOF
                systemctl restart NetworkManager.service
+
 
        
+
               systemctl restart NetworkManager.service
        else
+
 
     
+
       else
                cat << EOF > /etc/sysconfig/network-scripts/ifcfg-eth0
+
 
DEVICE=eth0
+
              cat << EOF > /etc/sysconfig/network-scripts/ifcfg-eth0
BOOTPROTO=dhcp
+
DEVICE=eth0
ONBOOT=yes
+
BOOTPROTO=dhcp
NM_CONTROLLED=yes
+
ONBOOT=yes
EOF
+
NM_CONTROLLED=yes
        
+
EOF
        fi
+
 
else
+
       fi
      systemctl stop headless-mode.service
+
else
      systemctl disable headless-mode.service
+
      systemctl stop headless-mode.service
fi
+
      systemctl disable headless-mode.service
+
fi
#read ip address
+
 
systemctl start ip-read.service
+
#Check headless file for resize option
#flashing ip address
+
 
systemctl start ip-flash.service
+
#Check headless file for resize and swap option
 +
grep -iE 'resize|swap' $headless
 +
 
 +
if [ $? -eq 0 -a ! -f /.resized ]
 +
then
 +
        touch /.rootfs-repartition
 +
        touch /.resized
 +
echo $swap | grep -o '[0-9]*' > /.swap
 +
        reboot
 +
else
 +
#resized already remove resize flag if it exists
 +
        rm -f /.rootfs-repartition
 +
rm -f /.swap
 +
fi
 +
 
 +
#read ip address
 +
systemctl start ip-read.service
 +
#flashing ip address
 +
systemctl start ip-flash.service

Revision as of 15:34, 7 June 2013

Pidora-horizontal.png
Important.png
Notice
Headless mode is currently a experimental feature, updates to headless mode and current issues can be found below

What is headless mode?

Headless mode is a system configuration in which the display device, keyboard, or mouse is lacking. When this feature is enabled, firstboot is bypassed.

Important.png
Security Warning!
If you are going to use headless mode it is critical that you change the root password as soon as possible, because Pidora is set with a default root password that is publicized.

Enabling headless mode on Pidora

To enable headless mode, you will need to create a file named "headless" in the boot filesystem on your SD card before you insert the card into your Pi.

On Linux:

Tutorial Video: http://youtu.be/ALUAmw6Mz_o

Insert the SD card into your system, and create a file named "headless" in the filesystem labelled "boot".

On Windows:

Insert the SD card into your system. Only the boot filesystem will be made available, because Windows will not be able to read other partitions on the card. Create a file named "headless" on that

Important.png
Note
If you are using a Windows OS you will need to remove the .txt file extension on the headless file. More information on removing file extensions on eHow

There are two possible configurations for headless-mode "DHCP" configuration and "Static" configuration.

DHCP Configuration

If you would like to obtain an ip address dynamically via DHCP, leave the "headless" file empty.

Static Configuration

If you would like to specify a specific IP address you will need to include the IP Address, Netmask and Gateway, place the following information in the "headless" file:

Sample headless file Static Configuration

IPADDR=192.168.1.105
NETMASK=255.255.255.0
GATEWAY=192.168.1.1

Headless Mode is enable with DHCP -- How do I find out my ip-address?

After you have enabled headless mode with either the DHCP configuration or Static IP configuration, the ip address that has been assigned to Raspberry Pi will be played through the speakers 2 minutes after you have powered the Raspberry Pi, and 30 seconds later it will also flash your ip address through Pi's OK/ACT LED.

More information about ip-read and ip-flash

Headless Mode Script Update

Initially there were a few issues with dchp and headless mode since our release the headless script has been updated. It has not been officially added to the updates repo yet but, if you are interested in trying this mode out now you can copy and replace the old headon script with the updated one located at /usr/bin/headon

  1. !/bin/bash

headless=`ls /boot/headless* 2> /dev/null | head -n 1` echo "Headless Mode Enabled" if [ -e "$headless" ] then

      systemctl enable sshd.service
      systemctl start sshd.service
      systemctl stop firstboot-graphical.service
      systemctl disable firstboot-graphical.service
      headtext=`grep '[0-9]' "$headless"`
      if [ "$headtext"  != "" ]
      then
              ip_address=$(sed -n 's/IPADDR=//p' $headless)
              ip_netmask=$(sed -n 's/NETMASK=//p' $headless)
              ip_gateway=$(sed -n 's/GATEWAY=//p' $headless)

swap_size=$(sed -n 's/SWAP=//p' $headless)

              cat << EOF > /etc/sysconfig/network-scripts/ifcfg-eth0

DEVICE=eth0 IPADDR=$ip_address NETMASK=$ip_netmask GATEWAY=$ip_gateway BOOTPROTO=static ONBOOT=yes NM_CONTROLLED=yes EOF

              systemctl restart NetworkManager.service
      else
              cat << EOF > /etc/sysconfig/network-scripts/ifcfg-eth0

DEVICE=eth0 BOOTPROTO=dhcp ONBOOT=yes NM_CONTROLLED=yes EOF

      fi

else

     systemctl stop headless-mode.service
     systemctl disable headless-mode.service

fi

  1. Check headless file for resize option
  1. Check headless file for resize and swap option

grep -iE 'resize|swap' $headless

if [ $? -eq 0 -a ! -f /.resized ] then

       touch /.rootfs-repartition
       touch /.resized

echo $swap | grep -o '[0-9]*' > /.swap

       reboot

else

  1. resized already remove resize flag if it exists
       rm -f /.rootfs-repartition

rm -f /.swap fi

  1. read ip address

systemctl start ip-read.service

  1. flashing ip address

systemctl start ip-flash.service