2014-11-26 11:33:58 +00:00
#!/bin/bash
2014-10-08 05:39:24 +00:00
### BEGIN INIT INFO
# Provides: firstrun
2014-10-12 18:39:42 +00:00
# Required-Start: $all
2014-10-08 05:39:24 +00:00
# Required-Stop:
2015-12-02 19:33:32 +00:00
# Should-Start: armhwinfo
2014-10-12 07:22:50 +00:00
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
2016-08-28 17:41:52 +00:00
# Short-Description: PLEASE DO NOT INTERRUPT THE FIRST BOOT
# Description: Something needs to be done when is
2014-10-08 05:39:24 +00:00
# starting at first time.
2014-10-12 07:22:50 +00:00
# regenerate ssh host key
2014-10-08 05:39:24 +00:00
### END INIT INFO
2016-01-13 11:10:21 +00:00
#
# Create this file to speed up boot process
#
2016-02-23 12:10:14 +00:00
2016-02-29 15:13:15 +00:00
# Immediately exit if not called by init system
2016-02-23 12:10:14 +00:00
if [ "X$1" != "Xstart" ]; then
exit 1
fi
export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
2016-06-08 20:04:12 +00:00
Log=/var/log/armhwinfo.log
2016-02-23 12:10:14 +00:00
# create helper script to set swap settings
2016-01-13 11:10:21 +00:00
cat > /tmp/create_swap.sh <<EOT
#!/bin/bash
2016-10-04 14:09:09 +00:00
#
2016-01-13 11:10:21 +00:00
# create swap and adds it into fstab
#
2016-08-25 06:35:38 +00:00
# update console info
setupcon --save
2016-02-19 13:15:09 +00:00
# SSH Keys creation
rm -f /etc/ssh/ssh_host*
dpkg-reconfigure openssh-server >/dev/null 2>&1
2016-06-09 21:21:51 +00:00
echo -e "### [firstrun] Recreated SSH keys" >>${Log}
2016-02-22 11:10:38 +00:00
MEMTOTAL=$(( $(awk -F" " '/^MemTotal/ {print $2}' </proc/meminfo) / 1024 ))
2016-01-30 18:31:48 +00:00
FREESIZE=\$(df -hm / | awk '/\// {print \$(NF-2)}')
2016-06-08 20:04:12 +00:00
SWAPFILE=/var/swap
2016-06-12 09:17:03 +00:00
if [[ ! -f "\$SWAPFILE" && "\$FREESIZE" -gt "132" ]]; then
fallocate -l 128M \$SWAPFILE >/dev/null 2>&1
if [ $? -eq 1 ]; then dd if=/dev/zero of=\$SWAPFILE bs=1M count=128 status=noxfer >/dev/null 2>&1; fi
chown root:root \$SWAPFILE
chmod 0600 \$SWAPFILE
mkswap \$SWAPFILE >/dev/null 2>&1
swapon \$SWAPFILE >/dev/null 2>&1
if ! grep -q swap /etc/fstab; then echo "\$SWAPFILE none swap sw 0 0" >> /etc/fstab; fi
2016-06-08 20:04:12 +00:00
if ! grep -q swap /etc/sysctl.conf; then echo "vm.swappiness=0" >> /etc/sysctl.conf; fi
2016-06-12 09:17:03 +00:00
echo -e "\n### [firstrun] Created 128MB emergency swap as \$SWAPFILE" >>${Log}
2016-01-13 11:10:21 +00:00
fi
# RAMLOG
if [[ "$(apt-cache policy ramlog | grep Installed)" != "" ]]; then
service ramlog enable
2016-10-04 14:09:09 +00:00
# if we have 1G ram reduce RAMLOG size
2016-02-22 11:10:38 +00:00
if [[ "\$MEMTOTAL" -lt "1100" ]]; then
2016-10-04 14:09:09 +00:00
if [ -f "/etc/default/ramlog" ]; then
2016-01-13 11:10:21 +00:00
sed -e 's/TMPFS_RAMFS_SIZE=512m/TMPFS_RAMFS_SIZE=256m/g' -i /etc/default/ramlog
fi
2016-02-22 11:10:38 +00:00
elif [[ "\$MEMTOTAL" -lt "600" ]]; then
2016-10-04 14:09:09 +00:00
if [ -f "/etc/default/ramlog" ]; then
2016-02-22 11:10:38 +00:00
sed -e 's/TMPFS_RAMFS_SIZE=512m/TMPFS_RAMFS_SIZE=192m/g' -i /etc/default/ramlog
fi
2016-01-13 11:10:21 +00:00
fi
fi
2016-03-13 08:34:25 +00:00
while [ -f /tmp/firstrun_running ]; do sleep 1; done
2016-08-28 17:41:52 +00:00
if [ -f "/var/run/reboot" ]; then
wall -n "Performing automatic reboot in 5 seconds"
sleep 5
reboot
fi
2016-01-13 11:10:21 +00:00
rm -f /tmp/create_swap.sh
2016-06-09 21:21:51 +00:00
sync &
2016-01-13 11:10:21 +00:00
EOT
chmod +x /tmp/create_swap.sh
2016-05-31 14:07:07 +00:00
collect_information() {
2016-02-23 12:10:14 +00:00
# get some info about the board
2016-06-18 14:28:02 +00:00
source /etc/armbian-release
2016-02-23 12:10:14 +00:00
DISTRIBUTION=$(lsb_release -cs)
2016-10-04 14:09:09 +00:00
2016-08-25 06:35:38 +00:00
# enable BT on cubietruck
[[ "$BOARD" == "cubietruck" ]] && update-rc.d brcm40183-patch defaults
2016-10-04 14:09:09 +00:00
2016-09-11 17:27:13 +00:00
# enable BT on Solidrun boards
[[ "$BOARD" == "Cubox i2eX/i4" ]] && update-rc.d brcm4330-patch defaults && /etc/init.d/brcm4330-patch start
2016-10-04 14:09:09 +00:00
2016-03-26 17:27:37 +00:00
case ${DISTRIBUTION} in
wheezy)
root_device=$(mountpoint -d /)
for file in /dev/* ; do
CURRENT_DEVICE=$(printf "%d:%d" $(stat --printf="0x%t 0x%T" $file))
if [ $CURRENT_DEVICE = $root_device ]; then
root_partition=$file
break;
fi
done
rootfstype=$(blkid -s TYPE -o value $root_partition)
;;
*)
ROOTFS=$(findmnt / | awk -F" " '/\/dev\// {print $2"\t"$3}')
set ${ROOTFS}
root_partition=$1
rootfstype=$2
;;
esac
2016-05-31 14:07:07 +00:00
} # collect_information
2014-10-08 05:39:24 +00:00
2016-05-31 14:07:07 +00:00
adjust_sunxi_settings() {
2016-06-06 15:08:56 +00:00
# set some mac address for BT
[[ "$(lsmod | grep bcmdhd)" != "" ]] && \
(MACADDR=$(printf '43:29:B1:%02X:%02X:%02X\n' $[RANDOM%256] $[RANDOM%256] $[RANDOM%256]) ; \
2016-06-08 20:04:12 +00:00
sed -i "s/^MAC_ADDR=.*/MAC_ADDR=${MACADDR}/" /etc/default/brcm40183 \
echo -e "\n### [firstrun] Use MAC address ${MACADDR} for Bluetooth from now" >>${Log})
2016-10-04 14:09:09 +00:00
2016-03-23 12:33:19 +00:00
# trigger red or blue LED as user feedback
2016-10-04 14:09:09 +00:00
echo heartbeat >/sys/class/leds/*red*/trigger 2>/dev/null || echo heartbeat >/sys/class/leds/*blue*/trigger 2>/dev/null
2016-03-07 15:41:03 +00:00
[ -f /etc/wicd/wired-settings.conf ] && \
2016-05-31 14:07:07 +00:00
read HOSTNAME </etc/hostname
sed -i "s/^dhcphostname =.*/dhcphostname = ${HOSTNAME}/" /etc/wicd/wired-settings.conf && \
2016-06-08 20:04:12 +00:00
sed -i "s/wpa_driver =.*/wpa_driver = none/" /etc/wicd/manager-settings.conf \
echo -e "\n### [firstrun] Use ${HOSTNAME} for wicd settings" >>${Log}
2016-05-31 14:07:07 +00:00
} # adjust_sunxi_settings
2016-02-22 11:10:38 +00:00
do_expand_rootfs() {
2016-03-26 17:27:37 +00:00
# get device node for boot media
2016-04-14 16:45:11 +00:00
DEVICE="/dev/"$(lsblk -idn -o NAME | grep -w mmcblk0)
2016-03-26 17:27:37 +00:00
if [ "${DEVICE}" = "/dev/" ]; then return ; fi
QUOTED_DEVICE=$(echo "${DEVICE}" | sed 's:/:\\\/:g')
2016-10-04 14:09:09 +00:00
2016-03-26 17:27:37 +00:00
# get count of partitions and their boundaries
2016-04-14 16:45:11 +00:00
PARTITIONS=$(( $(grep -c ${DEVICE##*/}p /proc/partitions) ))
2016-03-26 17:27:37 +00:00
PARTSTART=$(parted ${DEVICE} unit s print -sm | tail -1 | cut -d: -f2 | sed 's/s//') # start of first partition
PARTEND=$(parted ${DEVICE} unit s print -sm | head -3 | tail -1 | cut -d: -f3 | sed 's/s//') # end of first partition
STARTFROM=$(( ${PARTEND} + 1 ))
[[ ${PARTITIONS} == 1 ]] && STARTFROM=${PARTSTART}
2016-10-04 14:09:09 +00:00
2016-03-26 17:27:37 +00:00
# check whether a resizing rule is defined. We will take this value if it's not too low. In
# this case the value will be ignored and resizing to the whole card size happens.
if [ -f "/root/.rootfs_resize" ]; then
read RESIZE_VALUE <"/root/.rootfs_resize"
2016-06-08 20:04:12 +00:00
ResizeLog="Resize rule ${RESIZE_VALUE} defined for ${root_partition}"
2016-03-26 17:27:37 +00:00
case ${RESIZE_VALUE} in
*%)
# percentage value, we try to use 16MiB to align partitions since this is
# the erase block size of more recent SD cards (512 byte sectors, so we use 32
# as divider and substract 1)
PERCENTAGE=$(echo ${RESIZE_VALUE} | tr -c -d '[:digit:]')
LASTSECTOR=$(( 32 * $(parted ${DEVICE} unit s print -sm | awk -F":" "/^${QUOTED_DEVICE}/ {printf (\"%0d\", ( \$2 * ${PERCENTAGE} / 3200))}") -1 ))
if [ ${LASTSECTOR} -lt ${PARTEND} ]; then unset LASTSECTOR ; fi
;;
*s)
# sector value, we use it directly
LASTSECTOR=$(echo ${RESIZE_VALUE} | tr -c -d '[:digit:]')
if [ ${LASTSECTOR} -lt ${PARTEND} ]; then unset LASTSECTOR ; fi
;;
esac
else
2016-06-06 15:08:56 +00:00
# Unattended mode. We run a q&d benchmark to be able to identify cards way too slow easily
cd /root
2016-06-09 21:21:51 +00:00
echo -e "\n### quick iozone test:$(iozone -e -I -a -s 1M -r 4k -i 0 -i 1 -i 2 | grep '^ 1024' | sed 's/ 1024 //')" >>/var/log/armhwinfo.log
2016-06-06 15:08:56 +00:00
2016-03-26 17:27:37 +00:00
# check device capacity. If 4GB or below do not use whole card but leave a 5% spare area
# to help older cards with wear leveling and garbage collection. In case this reduced card
# capacity is less than the actual image capacity this is a clear sign that someone wants
# to use Armbian on a card of inappropriate size so he gets what he deserves (at least he
# should know what he's doing)
CAPACITY=$(parted ${DEVICE} unit s print -sm | awk -F":" "/^${QUOTED_DEVICE}/ {printf (\"%0d\", \$2 / ( 1024 / \$4 ))}")
if [ ${CAPACITY} -lt 4000000 ]; then
SPAREAREA=$(( ${CAPACITY} / 20000 ))
LASTSECTOR=$(parted ${DEVICE} unit s print -sm | awk -F":" "/^${QUOTED_DEVICE}/ {print \$2 - (${SPAREAREA} * 1024 * ( 1024 / \$4 ))}")
2016-06-08 20:04:12 +00:00
if [ ${LASTSECTOR} -lt ${PARTEND} ]; then
unset LASTSECTOR
else
ResizeLog="4GB media so leaving 200MB spare area on ${root_partition}"
fi
2016-06-06 15:08:56 +00:00
elif [ ${CAPACITY} -lt 8000000 ]; then
# Leave 2 percent unpartitioned
LASTSECTOR=$(( 32 * $(parted ${DEVICE} unit s print -sm | awk -F":" "/^${QUOTED_DEVICE}/ {printf (\"%0d\", ( \$2 * 98 / 3200))}") -1 ))
2016-06-08 20:04:12 +00:00
if [ ${LASTSECTOR} -lt ${PARTEND} ]; then
unset LASTSECTOR
else
ResizeLog="8GB media so leaving 2 percent spare area on ${root_partition}"
fi
2016-06-06 15:08:56 +00:00
else
# Leave 1 percent unpartitioned
2016-06-08 20:04:12 +00:00
LASTSECTOR=$(( 32 * $(parted ${DEVICE} unit s print -sm | awk -F":" "/^${QUOTED_DEVICE}/ {printf (\"%0d\", ( \$2 * 99 / 3200))}") -1 ))
if [ ${LASTSECTOR} -lt ${PARTEND} ]; then
unset LASTSECTOR
else
ResizeLog="Leaving 1 percent spare area on ${root_partition}"
fi
2016-03-26 17:27:37 +00:00
fi
fi
# Start resizing
2016-06-08 20:40:33 +00:00
echo -e "\n### [firstrun] ${ResizeLog}. Start resizing Partition now:\n" >>${Log}
2016-06-08 20:04:12 +00:00
cat /proc/partitions >>${Log}
2016-06-09 21:21:51 +00:00
echo -e "\nExecuting fdisk, fsck and partprobe:" >>${Log}
UtilLinuxVersion=$(echo q | fdisk ${DEVICE} | awk -F"util-linux " '/ fdisk / {print $2}')
if [ "X${PARTITIONS}" = "X1" ]; then
case ${UtilLinuxVersion} in
2.27.1*)
# if dealing with fdisk from util-linux 2.27.1 we need a workaround for just 1 partition
# https://github.com/igorpecovnik/lib/issues/353#issuecomment-224728506
((echo d; echo n; echo p; echo ; echo $STARTFROM; echo ${LASTSECTOR} ; echo w;) | fdisk ${DEVICE}) >>${Log} 2>&1 || true
;;
*)
((echo d; echo $PARTITIONS; echo n; echo p; echo ; echo $STARTFROM; echo ${LASTSECTOR} ; echo w;) | fdisk ${DEVICE}) >>${Log} 2>&1 || true
;;
esac
2016-06-08 21:30:58 +00:00
else
((echo d; echo $PARTITIONS; echo n; echo p; echo ; echo $STARTFROM; echo ${LASTSECTOR} ; echo w;) | fdisk ${DEVICE}) >>${Log} 2>&1 || true
fi
2016-10-04 14:09:09 +00:00
s=0
2016-06-09 21:21:51 +00:00
fsck -f $root_partition >>${Log} 2>&1 || true
partprobe ${DEVICE} >>${Log} 2>&1 || s=$?
2016-06-08 21:30:58 +00:00
echo -e "\nNew partition table:\n" >>${Log}
2016-06-08 20:04:12 +00:00
cat /proc/partitions >>${Log}
2016-06-09 21:21:51 +00:00
echo -e "\nNow executing resize2fs to enlarge ${root_partition} to the maximum:\n" >>${Log}
2016-06-08 20:04:12 +00:00
resize2fs $root_partition >>${Log} 2>&1 || true
2016-10-04 14:09:09 +00:00
2016-03-26 17:27:37 +00:00
# check whether reboot is necessary for resize2fs to take effect
2016-02-22 11:10:38 +00:00
FREESIZE=$(df -hm / | awk '/\// {print $(NF-2)}')
if [[ "$DISTRIBUTION" == "wheezy" || "$s" != "0" || "$FREESIZE" -lt "152" ]]; then
touch /var/run/reboot
2016-06-08 20:04:12 +00:00
update-rc.d resize2fs defaults >/dev/null 2>&1
2016-06-09 21:21:51 +00:00
echo -e "\n### [firstrun] Automated reboot needed to let /etc/init.d/resize2fs do the job" >>${Log}
2016-02-22 11:10:38 +00:00
fi
2016-02-23 12:10:14 +00:00
return 0
2016-05-31 14:07:07 +00:00
} # do_expand_rootfs
2014-10-08 05:39:24 +00:00
2016-02-29 15:13:15 +00:00
check_prerequisits() {
for needed_tool in fdisk parted partprobe resize2fs ; do
which ${needed_tool} >/dev/null 2>&1 || exit 1
done
} # check_prerequisits
2016-10-04 14:09:09 +00:00
do_firstrun_automated_user_configuration() {
2016-10-04 17:16:36 +00:00
#-----------------------------------------------------------------------------
2016-10-04 14:09:09 +00:00
#Requires:
# - sed
# - grep
# - cat
# - /usr/bin/killall
# - ifup & ifdown
2016-10-04 17:16:36 +00:00
#Notes:
# - If you change any variable name in this function, it MUST ALSO be changed in /boot/armbian_first_run.txt to match
# - Not sure where to put cp /lib/config/armbian_first_run.txt /boot/armbian_first_run.txt in ARMbian sourcecode?
2016-10-05 16:42:28 +00:00
# - Setting STATIC IP on BPi M2+ failed. No connection but setup correctly. Changed to DHCP = fine.
2016-10-04 14:09:09 +00:00
2016-10-04 17:16:36 +00:00
#-----------------------------------------------------------------------------
2016-10-05 16:42:28 +00:00
#Config FP
2016-10-04 17:16:36 +00:00
local fp_config='/boot/armbian_first_run.txt'
2016-10-04 14:09:09 +00:00
2016-10-04 17:16:36 +00:00
#-----------------------------------------------------------------------------
#Grab user requested settings
if [ -f "$fp_config" ]; then
2016-10-04 14:09:09 +00:00
2016-10-04 17:16:36 +00:00
# - Convert line endings to Unix from Dos. Prevents various issues where users modify file on another system, then save with dos line endings (eg: wordpad)
sed -i $'s/\r$//' "$fp_config"
2016-10-04 14:09:09 +00:00
2016-10-04 17:16:36 +00:00
# - Load vars directly from file
2016-10-05 16:42:28 +00:00
chmod +x "$fp_config" # possibly not required, need to test and confirm on ext4
2016-10-04 17:16:36 +00:00
. "$fp_config"
2016-10-04 14:09:09 +00:00
2016-10-04 17:16:36 +00:00
# - FR_general_delete_this_file_after_completion?
if (( $FR_general_delete_this_file_after_completion )); then
2016-10-04 14:09:09 +00:00
2016-10-04 17:16:36 +00:00
rm "$fp_config"
2016-10-04 14:09:09 +00:00
fi
2016-10-04 17:16:36 +00:00
fi
2016-10-04 14:09:09 +00:00
2016-10-04 17:16:36 +00:00
#-----------------------------------------------------------------------------
#Set Network
2016-10-04 14:09:09 +00:00
2016-10-05 16:42:28 +00:00
# - Get 1st active index of wlan and eth adapters
local fp_ifconfig_tmp='/tmp/.ifconfig'
ifconfig -a > "$fp_ifconfig_tmp" #export to file, should be quicker in loop than calling ifconfig each time.
# find eth[0-9]
for ((i=0; i<=9; i++))
do
if (( $(cat "$fp_ifconfig_tmp" | grep -ci -m1 "eth$i") )); then
eth_index=$i
break
fi
done
# find wlan[0-9]
for ((i=0; i<=9; i++))
do
if (( $(cat "$fp_ifconfig_tmp" | grep -ci -m1 "wlan$i") )); then
wlan_index=$i
break
fi
done
rm "$fp_ifconfig_tmp"
2016-10-04 17:16:36 +00:00
# - Kill dhclient
2016-10-05 16:42:28 +00:00
killall -w dhclient #FOURDEE: not needed as interfaces are disabled from up to this point
2016-10-04 14:09:09 +00:00
2016-10-04 17:16:36 +00:00
# - Drop Connections
2016-10-05 16:42:28 +00:00
ifdown eth$eth_index #FOURDEE: not needed as interfaces are disabled from up to this point
ifdown wlan$wlan_index #FOURDEE: not needed as interfaces are disabled from up to this point
2016-10-04 14:09:09 +00:00
2016-10-04 17:16:36 +00:00
# - Wifi enable
if (( $FR_net_wifi_enabled )); then
2016-10-04 14:09:09 +00:00
2016-10-04 17:16:36 +00:00
#Enable Wlan, disable Eth
FR_net_ethernet_enabled=0
2016-10-05 16:42:28 +00:00
sed -i "/allow-hotplug wlan$wlan_index/c\allow-hotplug wlan$wlan_index" /etc/network/interfaces
#sed -i "/allow-hotplug eth$eth_index/c\#allow-hotplug eth$eth_index" /etc/network/interfaces
2016-10-04 14:09:09 +00:00
2016-10-04 17:16:36 +00:00
#Set SSid (covers both WEP and WPA)
sed -i "/wireless-essid /c\ wireless-essid $FR_net_wifi_ssid" /etc/network/interfaces
sed -i "/wpa-ssid /c\ wpa-ssid $FR_net_wifi_ssid" /etc/network/interfaces
2016-10-04 14:09:09 +00:00
2016-10-04 17:16:36 +00:00
#Set Key (covers both WEP and WPA)
sed -i "/wireless-key /c\ wireless-key $FR_net_wifi_key" /etc/network/interfaces
sed -i "/wpa-psk /c\ wpa-psk $FR_net_wifi_key" /etc/network/interfaces
2016-10-04 14:09:09 +00:00
2016-10-04 17:16:36 +00:00
#Set country code
iw reg set "$FR_net_wifi_countrycode"
2016-10-04 14:09:09 +00:00
2016-10-04 17:16:36 +00:00
# - Ethernet enable
elif (( $FR_net_ethernet_enabled )); then
2016-10-04 14:09:09 +00:00
2016-10-04 17:16:36 +00:00
#Enable Eth, disable Wlan
FR_net_wifi_enabled=0
2016-10-05 16:42:28 +00:00
sed -i "/allow-hotplug eth$eth_index/c\allow-hotplug eth$eth_index" /etc/network/interfaces
#sed -i "/allow-hotplug wlan$wlan_index/c\#allow-hotplug wlan$wlan_index" /etc/network/interfaces
2016-10-04 17:16:36 +00:00
fi
# - Static IP enable
if (( $FR_net_use_static )); then
if (( $FR_net_wifi_enabled )); then
2016-10-05 16:42:28 +00:00
sed -i "/iface wlan$wlan_index inet/c\iface wlan$wlan_index inet static" /etc/network/interfaces
2016-10-04 14:09:09 +00:00
2016-10-04 17:16:36 +00:00
elif (( $FR_net_ethernet_enabled )); then
2016-10-05 16:42:28 +00:00
sed -i "/iface eth$eth_index inet/c\iface eth$eth_index inet static" /etc/network/interfaces
2016-10-04 14:09:09 +00:00
fi
2016-10-05 16:42:28 +00:00
#This will change both eth and wlan entries, but as only 1 adapater is enabled by this feature, should be fine.
2016-10-04 17:16:36 +00:00
sed -i "/^#address/c\address $FR_net_static_ip" /etc/network/interfaces
sed -i "/^#netmask/c\netmask $FR_net_static_mask" /etc/network/interfaces
sed -i "/^#gateway/c\gateway $FR_net_static_gateway" /etc/network/interfaces
sed -i "/^#dns-nameservers/c\dns-nameservers $FR_net_static_dns" /etc/network/interfaces
fi
# - Restart Networking
if [[ "$DISTRIBUTION" == "wheezy" || "$DISTRIBUTION" == "trusty" ]]; then
2016-10-04 14:09:09 +00:00
2016-10-04 17:16:36 +00:00
service networking restart
2016-10-04 14:09:09 +00:00
2016-10-04 17:16:36 +00:00
else
2016-10-04 14:09:09 +00:00
2016-10-04 17:16:36 +00:00
systemctl daemon-reload
systemctl restart networking
2016-10-04 14:09:09 +00:00
2016-10-04 17:16:36 +00:00
fi
2016-10-04 14:09:09 +00:00
2016-10-04 17:16:36 +00:00
# - Manually bring up adapters (just incase)
if (( $FR_net_wifi_enabled )); then
2016-10-04 14:09:09 +00:00
2016-10-05 16:42:28 +00:00
ifup wlan$wlan_index
2016-10-04 14:09:09 +00:00
2016-10-04 17:16:36 +00:00
elif (( $FR_net_ethernet_enabled )); then
2016-10-04 14:09:09 +00:00
2016-10-05 16:42:28 +00:00
ifup eth$eth_index
2016-10-04 14:09:09 +00:00
fi
} #do_firstrun_automated_user_configuration
2016-02-23 12:10:14 +00:00
main() {
2016-08-28 17:41:52 +00:00
touch /tmp/firstrun_running
2016-02-29 15:13:15 +00:00
check_prerequisits
2016-05-31 14:07:07 +00:00
collect_information
2016-02-23 12:10:14 +00:00
if [[ "$rootfstype" == "ext4" && ! -f "/root/.no_rootfs_resize" ]]; then
do_expand_rootfs
fi
2016-10-04 14:09:09 +00:00
do_firstrun_automated_user_configuration
2016-02-23 12:10:14 +00:00
/tmp/create_swap.sh &
2016-08-25 11:42:49 +00:00
# old distros can't handle allow-hotplug
if [[ "$DISTRIBUTION" == "wheezy" || "$DISTRIBUTION" == "trusty" ]]; then
2016-10-04 14:09:09 +00:00
sed -i "s/allow-hotplug eth0/auto eth0/" /etc/network/interfaces
2016-08-25 11:42:49 +00:00
fi
2016-10-04 14:09:09 +00:00
2016-06-18 14:28:02 +00:00
# some hardware workarounds
case ${LINUXFAMILY} in
sun7i|sun8i)
adjust_sunxi_settings
;;
pine64)
if [ -z "$(grep ethaddr /boot/uEnv.txt)" ] && [ -f "/sys/class/net/eth0/address" ]; then
echo "ethaddr=$(cat /sys/class/net/eth0/address)" >> /boot/uEnv.txt
fi
;;
esac
2016-05-05 13:49:46 +00:00
2016-02-23 12:10:14 +00:00
update-rc.d -f firstrun remove >/dev/null 2>&1
2016-03-13 08:34:25 +00:00
rm /tmp/firstrun_running
2016-02-23 12:10:14 +00:00
} # main
2014-10-08 05:39:24 +00:00
2016-06-08 20:40:33 +00:00
main