commit jeos-firstboot for openSUSE:Factory
Hello community, here is the log from the commit of package jeos-firstboot for openSUSE:Factory checked in at 2019-05-27 08:36:15 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/jeos-firstboot (Old) and /work/SRC/openSUSE:Factory/.jeos-firstboot.new.5148 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Package is "jeos-firstboot" Mon May 27 08:36:15 2019 rev:25 rq:704970 version:0.0+git20190523.f1f2bfa Changes: -------- --- /work/SRC/openSUSE:Factory/jeos-firstboot/jeos-firstboot.changes 2019-04-18 09:56:02.625326916 +0200 +++ /work/SRC/openSUSE:Factory/.jeos-firstboot.new.5148/jeos-firstboot.changes 2019-05-27 08:36:18.127119701 +0200 @@ -1,0 +2,28 @@ +Thu May 23 09:33:40 UTC 2019 - jeos-internal@suse.de + +- Update to version 0.0+git20190523.f1f2bfa: + * Fix broken function call in raspberrywifi, simplify + * Don't overwrite WiFi interface config + * Don't overwrite the cleanup trap + * Fix whitespace + * Don't use "if d", it never returns false + * Skip WiFi interface selection if there's only one + * Ignore setterm -msg failure + * Don't read stderr from dialog, use --output-fd instead + * Clean and fix raspberrywifi + * Fix module hook execution + * Fix warning on startup + * Fix typos/clarify comments in jeos-firstboot.conf + * Remove shebang and empty line in raspberrywifi + +------------------------------------------------------------------- +Tue May 21 12:06:23 UTC 2019 - jeos-internal@suse.de + +- Update to version 0.0+git20190521.23bc1d3: + * is_raspberry: do not show grep errors in non-rpi + * Configure all interfaces that resolves + * Allow to skip certain steps by setting values in a configuration file + * Execute external script(s) on firstboot +- Split module for WiFi configuration into subpackage + +------------------------------------------------------------------- Old: ---- jeos-firstboot-0.0+git20190417.7ba1ac9.tar.xz New: ---- jeos-firstboot-0.0+git20190523.f1f2bfa.tar.xz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ jeos-firstboot.spec ++++++ --- /var/tmp/diff_new_pack.I3BmqG/_old 2019-05-27 08:36:18.547119538 +0200 +++ /var/tmp/diff_new_pack.I3BmqG/_new 2019-05-27 08:36:18.551119536 +0200 @@ -12,12 +12,12 @@ # license that conforms to the Open Source Definition (Version 1.9) # published by the Open Source Initiative. -# Please submit bugfixes or comments via https://bugs.opensuse.org/ +# Please submit bugfixes or comments via http://bugs.opensuse.org/ # Name: jeos-firstboot -Version: 0.0+git20190417.7ba1ac9 +Version: 0.0+git20190523.f1f2bfa Release: 0 Summary: Simple text based JeOS first boot wizard License: MIT @@ -34,6 +34,18 @@ Simple text based JeOS first boot wizard that can be used instead of the line based one that is built into systemd. +%package rpiwifi +Summary: jeos-firstboot module for WiFi configuration for RaspberryPi systems +Group: Productivity/Networking/Other +Requires: %{name} = %{version} +Requires: wicked +Requires: wireless-tools +Requires: wpa_supplicant + +%description rpiwifi +This module hooks into jeos-firstboot and allows the user to enter data to connect +his RaspberryPi system to a wireless network. + %prep %setup -q @@ -58,7 +70,13 @@ %doc README examples/ifcfg-eth0 %license LICENSE %{_unitdir}/jeos-firstboot.service +%dir %{_datadir}/defaults/ +%{_datadir}/defaults/jeos-firstboot.conf +%dir %{_datadir}/jeos-firstboot %{_libexecdir}/jeos-firstboot %{_libexecdir}/jeos-firstboot-functions +%files rpiwifi +%{_datadir}/jeos-firstboot/raspberrywifi + %changelog ++++++ _servicedata ++++++ --- /var/tmp/diff_new_pack.I3BmqG/_old 2019-05-27 08:36:18.599119518 +0200 +++ /var/tmp/diff_new_pack.I3BmqG/_new 2019-05-27 08:36:18.603119516 +0200 @@ -1,4 +1,4 @@ <servicedata> <service name="tar_scm"> <param name="url">git://github.com/openSUSE/jeos-firstboot.git</param> - <param name="changesrevision">d96e7ed67002c8221948ec661a9b1e6011e1c264</param></service></servicedata> \ No newline at end of file + <param name="changesrevision">49ee57a359cd177e3dd1fe4d5739d2f87bdbb40a</param></service></servicedata> \ No newline at end of file ++++++ jeos-firstboot-0.0+git20190417.7ba1ac9.tar.xz -> jeos-firstboot-0.0+git20190523.f1f2bfa.tar.xz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/jeos-firstboot-0.0+git20190417.7ba1ac9/files/usr/lib/jeos-firstboot new/jeos-firstboot-0.0+git20190523.f1f2bfa/files/usr/lib/jeos-firstboot --- old/jeos-firstboot-0.0+git20190417.7ba1ac9/files/usr/lib/jeos-firstboot 2019-04-17 11:20:39.000000000 +0200 +++ new/jeos-firstboot-0.0+git20190523.f1f2bfa/files/usr/lib/jeos-firstboot 2019-05-23 11:33:19.000000000 +0200 @@ -26,50 +26,79 @@ . /etc/os-release . "$0-functions" +# Read the optional configuration file +[ -f /usr/share/defaults/jeos-firstboot.conf ] && . /usr/share/defaults/jeos-firstboot.conf +[ -f /etc/jeos-firstboot.conf ] && . /etc/jeos-firstboot.conf + stty_size() { - set -- `stty size`; LINES=$1; COLUMNS=$2 - # stty size can return zero when not ready or - # its a serial console - if [ "$COLUMNS" = "0" -o "$LINES" = "0" ]; then - LINES=24 - COLUMNS=80 - fi -}; stty_size + set -- `stty size`; LINES=$1; COLUMNS=$2 + # stty size can return zero when not ready or + # its a serial console + if [ "$COLUMNS" = "0" -o "$LINES" = "0" ]; then + LINES=24 + COLUMNS=80 + fi +} +stty_size # for testing we may run as non root if [ -w /run ]; then - export TMPDIR=/run - # debugging - if [ -n "$FIRSTBOOT_DEBUG" ]; then - set -x - exec 2>/var/log/firstboot-debug - fi + export TMPDIR=/run + # debugging + if [ -n "$FIRSTBOOT_DEBUG" ]; then + set -x + exec 2>/var/log/firstboot-debug + fi else - dry=1 + dry=1 fi if [ -n "$dry" ]; then - run() { - echo "$@" - } + run() { + echo "$@" + } else - run() { - "$@" - } + run() { + "$@" + } +fi + +modules=() + +call_module_hook() { + local hook="$1" + for module in "${modules[@]}"; do + hook_function="${module}_${hook}" + [ "$(type -t "${hook_function}")" = "function" ] || continue + "${hook_function}" && true # To not trigger errexit + ret=$? + [ $ret -eq 0 ] || return $ret + done + return 0 +} + +if pushd "/usr/share/jeos-firstboot" &>/dev/null; then + for module in *; do + if [ -f "${module}" ] && source "${module}"; then + modules+=("${module}") + fi + done + popd &>/dev/null fi dialog_out=`mktemp -qt 'firstboot-XXXXXX'` cleanup() { + call_module_hook cleanup echo .oOo.oOo.oOo. > $dialog_out rm -f "$dialog_out" # reenable systemd and kernel logs run kill -s SIGRTMAX-10 1 - run setterm -msg on + run setterm -msg on 2>/dev/null || true } trap cleanup EXIT # avoid kernel messages spamming our console -run setterm -msg off +run setterm -msg off 2>/dev/null || true # Avoid systemd messages spamming our console run kill -s SIGRTMAX-9 1 # sleep to avoid systemd bug, bsc#1119382 @@ -77,162 +106,156 @@ systemd_firstboot_args=('--setup-machine-id') +# If the configuration is not loaded and we are in the first terminal +# instance, make sure that the variables are declared. +JEOS_LOCALE=${JEOS_LOCALE-} +JEOS_KEYTABLE=${JEOS_KEYTABLE-} + result= list= -keytable='' -locale='' password='' let dh_menu=LINES-15 let dh_text=LINES-5 d(){ - retval= - while true - do - dialog --backtitle "$PRETTY_NAME" "$@" 2>"$dialog_out" - retval=$? - case $retval in - 0) - # need || true as dialog doesn't write newlines - read result < $dialog_out || true - return 0 - ;; - 1) - dialog --yesno $"Do you really want to quit?" 0 0 && exit 1 - continue - ;; - 255) - # xargs to remove whitespaces - result_error="$(xargs -a "$dialog_out")" - if [ -z "$result_error" ]; then - dialog --yesno $"Do you really want to quit?" 0 0 && exit 1 - continue - fi - logger -p err -t jeos-firstboot "$result_error" - dialog --msgbox $"Exiting due to error, please check the system log" 0 0 - exit 2 - ;; - esac - done + retval= + while true + do + dialog --backtitle "$PRETTY_NAME" --output-fd 3 "$@" 3>"${dialog_out}" + retval=$? + case $retval in + 0) + # need || true as dialog doesn't write newlines + read result < $dialog_out || true + return 0 + ;; + 1) + dialog --yesno $"Do you really want to quit?" 0 0 && exit 1 + continue + ;; + 255) + # xargs to remove whitespaces + result_error="$(xargs -a "$dialog_out")" + if [ -z "$result_error" ]; then + dialog --yesno $"Do you really want to quit?" 0 0 && exit 1 + continue + fi + logger -p err -t jeos-firstboot "$result_error" + dialog --msgbox $"Exiting due to error, please check the system log" 0 0 + exit 2 + ;; + esac + done } warn(){ - d --title $"Warning" --msgbox "$1" 6 40 + d --title $"Warning" --msgbox "$1" 6 40 } menulist() { - list=() - local line - while read line; do - list+=("$line" '') - done < <("$@"||true) - [ -n "$list" ] + list=() + local line + while read line; do + list+=("$line" '') + done < <("$@"||true) + [ -n "$list" ] } # for some reason localectl doesn't work here #menulist localectl --no-pager list-keymaps findkeymaps() { - list=() - local line - while read line; do - list+=("${line%.map.gz}" '') - done < <(find /usr/share/kbd/keymaps -name '*.map.gz' -printf "%f\n" | sort -u) - [ -n "$list" ] + list=() + local line + while read line; do + list+=("${line%.map.gz}" '') + done < <(find /usr/share/kbd/keymaps -name '*.map.gz' -printf "%f\n" | sort -u) + [ -n "$list" ] } findlocales() { - list=() - local l locale - # List only locales which are both in live-langset-data and glibc-locale(-base) - for l in /usr/share/langset/*; do - locale="${l#/usr/share/langset/}" - [ -d "/usr/lib/locale/${locale}.utf8" ] || continue - list+=("${locale}" '') - done - [ -n "$list" ] + list=() + local l locale + # List only locales which are both in live-langset-data and glibc-locale(-base) + for l in /usr/share/langset/*; do + locale="${l#/usr/share/langset/}" + [ -d "/usr/lib/locale/${locale}.utf8" ] || continue + list+=("${locale}" '') + done + [ -n "$list" ] } -if [ -z "$LOCALE_PRESET" ]; then - default="en_US" - [ -f /etc/locale.conf ] && locale_lang="$(awk -F= '$1 == "LANG" { split($2,fs,"."); print fs[1]; exit }' /etc/locale.conf)" - [ -n "$locale_lang" ] && default="$locale_lang" - - list=() # Set by findlocales - newlocale="$default" - if ! findlocales; then - d --msgbox $"No locales found" 0 0 - elif [ "${#list[@]}" -eq 2 ]; then - newlocale="${list[0]}" - d --msgbox $"Locale set to $newlocale.\nTo change to a different one, install glibc-locale and use\n'localectl set-locale LANG=ex_AMPLE.UTF-8'." 8 50 - else - d --default-item "$default" --menu $"Select System Locale" 0 0 $dh_menu "${list[@]}" - newlocale="${result}" - fi - - if [ -n "$newlocale" ]; then - locale="${newlocale}.UTF-8" - systemd_firstboot_args+=("--locale=$locale") - - # Run langset to get consolefont and keymap set up - run langset.sh $locale || warn $"Setting the locale failed" - fi -else - locale="$LOCALE_PRESET" - systemd_firstboot_args+=("--locale=$locale") +if [ -z "$JEOS_LOCALE" ]; then + default="en_US" + [ -f /etc/locale.conf ] && locale_lang="$(awk -F= '$1 == "LANG" { split($2,fs,"."); print fs[1]; exit }' /etc/locale.conf)" + [ -n "$locale_lang" ] && default="$locale_lang" + + list=() # Set by findlocales + newlocale="$default" + if ! findlocales; then + d --msgbox $"No locales found" 0 0 + elif [ "${#list[@]}" -eq 2 ]; then + newlocale="${list[0]}" + d --msgbox $"Locale set to $newlocale.\nTo change to a different one, install glibc-locale and use\n'localectl set-locale LANG=ex_AMPLE.UTF-8'." 8 50 + else + d --default-item "$default" --menu $"Select System Locale" 0 0 $dh_menu "${list[@]}" + newlocale="${result}" + fi + + JEOS_LOCALE="${newlocale}.UTF-8" fi -if [ -z "$KEYTABLE_PRESET" ]; then - default="us" - [ -f /etc/vconsole.conf ] && vconsole_keymap="$(awk -F= '$1 == "KEYMAP" { split($2,fs,"."); print fs[1]; exit }' /etc/vconsole.conf)" - [ -n "$vconsole_keymap" ] && default="$vconsole_keymap" - - if findkeymaps \ - && d --default-item "$default" --menu $"Select Keyboard Layout" 0 0 $dh_menu "${list[@]}"; then - if [ -n "$result" ]; then - keytable="$result" - - # Activate the selected keyboard layout - run langset.sh "$locale" "$keytable" || warn $"Setting the keyboard layout failed" - fi - else - d --msgbox $"Error setting keyboard" 0 0 - fi -else - keytable="$result" +run langset.sh $JEOS_LOCALE || warn $"Setting the locale failed" +systemd_firstboot_args+=("--locale=$JEOS_LOCALE") + +if [ -z "$JEOS_KEYTABLE" ]; then + default="us" + [ -f /etc/vconsole.conf ] && vconsole_keymap="$(awk -F= '$1 == "KEYMAP" { split($2,fs,"."); print fs[1]; exit }' /etc/vconsole.conf)" + [ -n "$vconsole_keymap" ] && default="$vconsole_keymap" + + if findkeymaps \ + && d --default-item "$default" --menu $"Select Keyboard Layout" 0 0 $dh_menu "${list[@]}"; then + if [ -n "$result" ]; then + JEOS_KEYTABLE="$result" + fi + else + d --msgbox $"Error setting keyboard" 0 0 + fi +fi + +if [ ! -z "$JEOS_LOCALE" -a ! -z "$JEOS_KEYTABLE" ]; then + # Activate the selected keyboard layout + run langset.sh "$JEOS_LOCALE" "$JEOS_KEYTABLE" || warn $"Setting the keyboard layout failed" fi -[ -n "${locale}" ] && language="${locale%%_*}" || language="en" +[ -n "$JEOS_LOCALE" ] && language="${JEOS_LOCALE%%_*}" || language="en" force_english_license=0 -export LANG="$locale" +export LANG="$JEOS_LOCALE" if [[ "$(ps h -o tty -p $$)" = tty[0-9]* ]]; then - # Those languages can't be displayed in the console - declare -A start_kmscon - start_kmscon["cs"]=1 - start_kmscon["ja"]=1 - start_kmscon["zh"]=1 - start_kmscon["ko"]=1 - - if [ -n "$locale" -a -n "${start_kmscon[${language}]+_}" ]; then - export LOCALE_PRESET="$locale" - export KEYTABLE_PRESET="$keytable" - - if kmscon_available; then - ret_file="$(mktemp)" - kmscon --silent --font-size 10 --palette vga --no-reset-env -l -- /bin/sh -c "$0; echo \$? > $ret_file; kill \$PPID" - exit $(cat "$ret_file"; rm -f "$ret_file") - elif fbiterm_available; then - exec fbiterm -- "$0" - else - # No kmscon or fbiterm, fall back to english - export LANG="en_US.UTF-8" - force_english_license=1 - fi - fi + # Those languages can't be displayed in the console + declare -A start_kmscon + start_kmscon["cs"]=1 + start_kmscon["ja"]=1 + start_kmscon["zh"]=1 + start_kmscon["ko"]=1 + + if [ -n "$JEOS_LOCALE" -a -n "${start_kmscon[${language}]+_}" ]; then + if kmscon_available; then + ret_file="$(mktemp)" + kmscon --silent --font-size 10 --palette vga --no-reset-env -l -- /bin/sh -c "$0; echo \$? > $ret_file; kill \$PPID" + exit $(cat "$ret_file"; rm -f "$ret_file") + elif fbiterm_available; then + exec fbiterm -- "$0" + else + # No kmscon or fbiterm, fall back to english + export LANG="en_US.UTF-8" + force_english_license=1 + fi + fi fi # Find the location of the EULA @@ -247,67 +270,68 @@ fi if [ -e "$EULA_FILE" -a ! -e "${EULA_FILE%/*}/no-acceptance-needed" ]; then - if [ "$force_english_license" = "0" ]; then - for i in "${EULA_FILE%.txt}.$locale.txt" \ - "${EULA_FILE%.txt}.${locale%%.UTF-8}.txt" \ - "${EULA_FILE%.txt}.${language}.txt"; do - if [ -e "$i" ]; then - EULA_FILE="$i" - break - fi - done - fi - - while ! dialog --backtitle "$PRETTY_NAME" --textbox "$EULA_FILE" $dh_text 85 --and-widget --yesno $"Do you agree with the terms of the license?" 0 0; do - d --msgbox $"Well, we cannot continue then ..." 6 40 - done + if [ "$force_english_license" = "0" ]; then + for i in "${EULA_FILE%.txt}.${JEOS_LOCALE}.txt" \ + "${EULA_FILE%.txt}.${JEOS_LOCALE%%.UTF-8}.txt" \ + "${EULA_FILE%.txt}.${language}.txt"; do + if [ -e "$i" ]; then + EULA_FILE="$i" + break + fi + done + fi + + while ! dialog --backtitle "$PRETTY_NAME" --textbox "$EULA_FILE" $dh_text 85 --and-widget --yesno $"Do you agree with the terms of the license?" 0 0; do + d --msgbox $"Well, we cannot continue then ..." 6 40 + done fi default="$(readlink -f /etc/localtime)" default="${default##/usr/share/zoneinfo/}" -# timedatectl doesn't work as dbus is not up yet -# menulist timedatectl --no-pager list-timezones -if menulist awk \ - 'BEGIN{print "UTC"; sort="sort"}/^#/{next;}{print $3|sort}END{close(sort)}' \ - /usr/share/zoneinfo/zone.tab \ - && d --default-item "$default" --menu $"Select Time Zone" 0 0 $dh_menu "${list[@]}"; then +if [ -z "$JEOS_TIMEZONE" ]; then + # timedatectl doesn't work as dbus is not up yet + # menulist timedatectl --no-pager list-timezones + if menulist awk \ + 'BEGIN{print "UTC"; sort="sort"}/^#/{next;}{print $3|sort}END{close(sort)}' \ + /usr/share/zoneinfo/zone.tab \ + && d --default-item "$default" --menu $"Select Time Zone" 0 0 $dh_menu "${list[@]}"; then if [ -n "$result" ]; then - systemd_firstboot_args+=("--timezone=$result") + JEOS_TIMEZONE="$result" + fi + else + d --msgbox $"error setting timezone" 0 0 fi -else - d --msgbox $"error setting timezone" 0 0 fi +systemd_firstboot_args+=("--timezone=$JEOS_TIMEZONE") # systemd-firstboot does not set the timezone if it exists, langset.sh created it run rm -f /etc/localtime run systemd-firstboot "${systemd_firstboot_args[@]}" -# NOTE: must be last as dialog file is used to set the password -while true; do - password= - if d --insecure --passwordbox $"Enter root Password" 0 0; then - password="$result" - if d --insecure --passwordbox $"Confirm root Password" 0 0; then - if [ "$password" != "$result" ]; then - d --msgbox $"Entered passwords don't match" 5 40 || true - continue - fi - # don't use that one as we need to switch locale - #systemd_firstboot_args+=("--root-password-file=$dialog_out") - fi - fi - if [ -z "$password" ]; then - warn $"Warning: No root password set. +if [ -z "$JEOS_PASSWORD_ALREADY_SET" ]; then + while true; do + d --insecure --passwordbox $"Enter root Password" 0 0 + password="$result" + d --insecure --passwordbox $"Confirm root Password" 0 0 + if [ "$password" != "$result" ]; then + d --msgbox $"Entered passwords don't match" 5 40 + continue + fi + # don't use that one as we need to switch locale + #systemd_firstboot_args+=("--root-password-file=$dialog_out") + if [ -z "$password" ]; then + warn $"Warning: No root password set. You cannot log in that way. A debug shell will be started on tty9 just this time. Use it to e.g. import your ssh key." 0 0 || true - run systemctl start debug-shell.service - fi - break -done + run systemctl start debug-shell.service + fi + break + done +fi if [ -x /usr/bin/SUSEConnect ]; then - d --msgbox $"Please register this image using your existing SUSE entitlement. + d --msgbox $"Please register this image using your existing SUSE entitlement. As \"root\" use the following command: @@ -324,165 +348,57 @@ # shopt -s nullglob -candidates=() for p in /sys/class/net/* ; do - test -f "$p" && continue # skip bonding_masters file - - # only devices having ID_NET_NAME.* attrs - udevadm info -q all -p "$p" | grep -qs ID_NET_NAME || continue - d=${p##*/} - - unset IPADDR GATEWAYS - eval `wicked test dhcp4 "$d" 2>/dev/null | grep -E "^IPADDR=|^GATEWAYS="` - ip link set down "$d" # set link down after probe once done - - test -n "$IPADDR" && candidates+=("$d") || continue # ok, track it - test -n "$GATEWAYS" && candidates=("$d") || continue # just use it - break -done + test -f "$p" && continue # skip bonding_masters file -for d in ${candidates[@]} ; do - rm -f "/etc/sysconfig/network/ifcfg-$d" || exit 1 - printf "STARTMODE=auto\nBOOTPROTO=dhcp\n" \ - > "/etc/sysconfig/network/ifcfg-$d" - break # one is enough + # only devices having ID_NET_NAME.* attrs + udevadm info -q property -p "$p" | grep -qs ID_NET_NAME || continue + # But don't touch WLAN interfaces + udevadm info -q property -p "$p" | grep -qs "DEVTYPE=wlan" && continue + + d=${p##*/} + + unset IPADDR + eval `wicked test dhcp4 "$d" 2>/dev/null | grep -E "^IPADDR="` + ip link set down "$d" # set link down after probe once done + + # Create a configuration file for each interface that provides + # an IPADDR + if [ -n "$IPADDR" ]; then + rm -f "/etc/sysconfig/network/ifcfg-$d" || exit 1 + printf "STARTMODE=auto\nBOOTPROTO=dhcp\n" \ + > "/etc/sysconfig/network/ifcfg-$d" + fi done -config_wireless=false -if is_raspberry && ls -d /sys/class/net/*/wireless &>/dev/null; then - if dialog --yesno $"Configure wireless network?" 0 0; then - config_wireless=true - fi -fi -if [ "$config_wireless" = "true" ]; then - # Wi-fi - # - get_wlan_devices() - { - list=() - local line - while read line; do - list+=("${line}" '') - done < <(ls -d /sys/class/net/*/wireless | awk -F'/' '{ print $5 }') - [ -n "$list" ] - } - - get_wlan_networks() - { - list=() - local line - while read line; do - list+=("${line}" '') - done < <(ip link set $wlan_device up && iwlist $wlan_device scan|grep ESSID|cut -d':' -f2|cut -d'"' -f2|sort -u) - [ -n "${list[*]}" ] - } - - wlan_error(){ - d --title $"Error" --msgbox "$1" 0 0 - dialog --yesno $"Do you want to retry?" 0 0 - } - while true - do - if get_wlan_devices && d --menu $"Select Wireless card to configure" 0 0 $dh_menu "${list[@]}"; then - wlan_device="$result" - else - if wlan_error $"Error listing wlan devices"; then - continue - else - break - fi - fi - - if get_wlan_networks && d --menu $"Select Wireless network to connect" 0 0 $dh_menu "${list[@]}"; then - wlan_network="$result" - else - if wlan_error $"Error listing wireless networks"; then - continue - else - break - fi - fi - - if d --menu $"Select authentication mode" 0 0 $dh_menu $"WPA-PSK" '' $"WPA-EAP" '' $"Open" ''; then - wlan_auth_mode="$result" - fi - wlan_auth_mode_conf= - if [ "$wlan_auth_mode" = "WPA-EAP" ]; then - wlan_auth_mode_conf=eap - if d --inputbox $"Username" 0 0; then - wlan_username="$result" - fi - fi - if [ "$wlan_auth_mode" = "WPA-PSK" ]; then - wlan_auth_mode_conf=psk - fi - if [ "$wlan_auth_mode" = "Open" ]; then - wlan_auth_mode_conf=open - fi - if [ "$wlan_auth_mode" != "Open" ]; then - wlan_password= - if d --insecure --passwordbox $"Password" 0 0; then - wlan_password="$result" - fi - fi - break - done - - config_file=`mktemp -qt 'firstboot-XXXXXX'` - - cat << EOF > $config_file -BOOTPROTO='dhcp' -STARTMODE='auto' -WIRELESS_AP_SCANMODE='1' -WIRELESS_AUTH_MODE='$wlan_auth_mode_conf' -WIRELESS_ESSID='$wlan_network' -WIRELESS_MODE='Managed' -EOF - - if [ $wlan_auth_mode = "WPA-PSK" ]; then - echo "WIRELESS_WPA_PSK='$wlan_password'" >> $config_file - fi - - if [ $wlan_auth_mode = "WPA-EAP" ]; then - echo "WIRELESS_WPA_IDENTITY='$wlan_username'" >> $config_file - echo "WIRELESS_WPA_PASSWORD='$wlan_password'" >> $config_file - echo "WIRELESS_EAP_AUTH='mschapv2'" >> $config_file - fi - - run mv -f $config_file /etc/sysconfig/network/ifcfg-$wlan_device - -fi +call_module_hook systemd_firstboot d --infobox $"Applying firstboot settings ..." 3 40 || true # FIXME: systemd-firstboot doesn't set password if shadow present if [ -n "$password" ]; then - run echo "root:$password" | run /usr/sbin/chpasswd + run echo "root:$password" | run /usr/sbin/chpasswd fi EFI_SYSTAB="/sys/firmware/efi/systab" # Look for EFI dir to see if the machine is booted in UEFI mode run modprobe efivars if ! [ -f "$EFI_SYSTAB" ]; then - run sed -i -e "s/LOADER_TYPE=.*/LOADER_TYPE=grub2/g" /etc/sysconfig/bootloader + run sed -i -e "s/LOADER_TYPE=.*/LOADER_TYPE=grub2/g" /etc/sysconfig/bootloader fi # Test if snapper is available -if [ -x /usr/bin/snapper ]; then - if ! btrfs qgroup show / &>/dev/null; then - # Run snapper to setup quota for btrfs - run /usr/bin/snapper --no-dbus setup-quota || warn $"Could not setup quota for btrfs" - fi - - if [ ! -e /.snapshots/2 ]; then - run create_snapshot 2 "Initial Status" "yes" || true - fi - if [ -x /usr/lib/snapper/plugins/grub ]; then - run /usr/lib/snapper/plugins/grub --refresh - fi -fi - -if [ "$config_wireless" = "true" ]; then - run ifdown $wlan_device 2>/dev/null || true - run ifup $wlan_device || true +if [ -x /usr/bin/snapper -a "$(stat --format=%T -f /)" = "btrfs" ]; then + if ! btrfs qgroup show / &>/dev/null; then + # Run snapper to setup quota for btrfs + run /usr/bin/snapper --no-dbus setup-quota || warn $"Could not setup quota for btrfs" + fi + + if [ ! -e /.snapshots/2 ]; then + run create_snapshot 2 "Initial Status" "yes" || true + fi + if [ -x /usr/lib/snapper/plugins/grub ]; then + run /usr/lib/snapper/plugins/grub --refresh + fi fi -# vim: sw=4 + +call_module_hook post diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/jeos-firstboot-0.0+git20190417.7ba1ac9/files/usr/lib/jeos-firstboot-functions new/jeos-firstboot-0.0+git20190523.f1f2bfa/files/usr/lib/jeos-firstboot-functions --- old/jeos-firstboot-0.0+git20190417.7ba1ac9/files/usr/lib/jeos-firstboot-functions 2019-04-17 11:20:39.000000000 +0200 +++ new/jeos-firstboot-0.0+git20190523.f1f2bfa/files/usr/lib/jeos-firstboot-functions 2019-05-23 11:33:19.000000000 +0200 @@ -44,24 +44,20 @@ } kmscon_available() { - # kmscon itself is installed - kmscon --help >/dev/null 2>&1 || return 1 - # At least one monospace font is available - [ -n "$(fc-match "monospace" 2>/dev/null)" ] || return 1 + # kmscon itself is installed + kmscon --help >/dev/null 2>&1 || return 1 + # At least one monospace font is available + [ -n "$(fc-match "monospace" 2>/dev/null)" ] || return 1 - return 0 + return 0 } fbiterm_available() { - # fbiterm itself is installed - fbiterm --help >/dev/null 2>&1 || return 1 - # fbiterm comes with its own fallback font + # fbiterm itself is installed + fbiterm --help >/dev/null 2>&1 || return 1 + # fbiterm comes with its own fallback font - return 0 -} - -is_raspberry() { - grep -q Raspberry /proc/device-tree/model + return 0 } # vim: syntax=sh diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/jeos-firstboot-0.0+git20190417.7ba1ac9/files/usr/share/defaults/jeos-firstboot.conf new/jeos-firstboot-0.0+git20190523.f1f2bfa/files/usr/share/defaults/jeos-firstboot.conf --- old/jeos-firstboot-0.0+git20190417.7ba1ac9/files/usr/share/defaults/jeos-firstboot.conf 1970-01-01 01:00:00.000000000 +0100 +++ new/jeos-firstboot-0.0+git20190523.f1f2bfa/files/usr/share/defaults/jeos-firstboot.conf 2019-05-23 11:33:19.000000000 +0200 @@ -0,0 +1,18 @@ +# Example configuration file for jeos-firstboot + +# Valid system locale that will be used in JeOS. If empty/unset, a +# dialog box will ask for the system locale. +# JEOS_LOCALE='en_US' + +# Keyboard layout used in the system and during jeos-firstboot. +# If empty/unset, a dialog box will ask for the keyboard layout. +# JEOS_KEYTABLE='en' + +# Local timezone of the system. +# If empty/unset, a dialog box will ask for the local timezone. +# JEOS_TIMEZONE='UTC' + +# If set to a nonempty value, the dialog box for setting the +# initial password for the root user will be skipped. In this case is +# expected that the root password was set by other means. +# JEOS_PASSWORD_ALREADY_SET='yes' diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/jeos-firstboot-0.0+git20190417.7ba1ac9/files/usr/share/jeos-firstboot/raspberrywifi new/jeos-firstboot-0.0+git20190523.f1f2bfa/files/usr/share/jeos-firstboot/raspberrywifi --- old/jeos-firstboot-0.0+git20190417.7ba1ac9/files/usr/share/jeos-firstboot/raspberrywifi 1970-01-01 01:00:00.000000000 +0100 +++ new/jeos-firstboot-0.0+git20190523.f1f2bfa/files/usr/share/jeos-firstboot/raspberrywifi 2019-05-23 11:33:19.000000000 +0200 @@ -0,0 +1,144 @@ +# Copyright (c) 2019 SUSE LLC +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + +config_wireless=false + +# Raspberry pi Wi-fi functions +raspberrywifi_get_wlan_devices() +{ + list=() + local line + while read line; do + list+=("${line}" '') + done < <(ls -d /sys/class/net/*/wireless | awk -F'/' '{ print $5 }') + [ -n "$list" ] +} + +raspberrywifi_get_wlan_networks() +{ + list=() + local line + while read line; do + list+=("${line}" '') + done < <(ip link set $wlan_device up && iwlist $wlan_device scan|grep ESSID|cut -d':' -f2|cut -d'"' -f2|sort -u) + [ -n "${list[*]}" ] +} + +raspberrywifi_wlan_error() +{ + d --title $"Error" --msgbox "$1" 0 0 + dialog --yesno $"Do you want to retry?" 0 0 +} + +is_raspberry() +{ + grep -q Raspberry /proc/device-tree/model 2> /dev/null +} + +# This is called by jeos-firstboot for user +# interaction and access to the global systemd_firstboot_args array +raspberrywifi_systemd_firstboot() +{ + if is_raspberry && ls -d /sys/class/net/*/wireless &>/dev/null; then + if dialog --yesno $"Configure wireless network?" 0 0; then + config_wireless=true + fi + fi + [ "$config_wireless" = "true" ] || return 0 + + while true + do + if ! raspberrywifi_get_wlan_devices; then + if raspberrywifi_wlan_error $"Error listing wlan devices"; then + continue + fi + break + fi + + if [ "${#list[@]}" -eq "2" ]; then + wlan_device="${list[0]}" + else + d --menu $"Select Wireless card to configure" 0 0 $dh_menu "${list[@]}" + wlan_device="${result}" + fi + + if raspberrywifi_get_wlan_networks && d --menu $"Select Wireless network to connect" 0 0 $dh_menu "${list[@]}"; then + wlan_network="$result" + else + if raspberrywifi_wlan_error $"Error listing wireless networks"; then + continue + fi + break + fi + + d --menu $"Select authentication mode" 0 0 $dh_menu $"WPA-PSK" '' $"WPA-EAP" '' $"Open" '' + wlan_auth_mode="$result" + + wlan_auth_mode_conf= + if [ "$wlan_auth_mode" = "WPA-EAP" ]; then + wlan_auth_mode_conf=eap + d --inputbox $"Username" 0 0 + wlan_username="$result" + fi + if [ "$wlan_auth_mode" = "WPA-PSK" ]; then + wlan_auth_mode_conf=psk + fi + if [ "$wlan_auth_mode" = "Open" ]; then + wlan_auth_mode_conf=open + fi + if [ "$wlan_auth_mode" != "Open" ]; then + wlan_password= + d --insecure --passwordbox $"Password" 0 0 + wlan_password="$result" + fi + break + done + + config_file=`mktemp -qt 'firstboot-XXXXXX'` + + cat << EOF > $config_file +BOOTPROTO='dhcp' +STARTMODE='auto' +WIRELESS_AP_SCANMODE='1' +WIRELESS_AUTH_MODE='$wlan_auth_mode_conf' +WIRELESS_ESSID='$wlan_network' +WIRELESS_MODE='Managed' +EOF + + if [ $wlan_auth_mode = "WPA-PSK" ]; then + echo "WIRELESS_WPA_PSK='$wlan_password'" >> $config_file + fi + + if [ $wlan_auth_mode = "WPA-EAP" ]; then + echo "WIRELESS_WPA_IDENTITY='$wlan_username'" >> $config_file + echo "WIRELESS_WPA_PASSWORD='$wlan_password'" >> $config_file + echo "WIRELESS_EAP_AUTH='mschapv2'" >> $config_file + fi + + run mv -f $config_file /etc/sysconfig/network/ifcfg-$wlan_device +} + +# This is called after the configuration steps finished successfully +raspberrywifi_post() +{ + [ "$config_wireless" = "true" ] || return 0 + run ifdown $wlan_device 2>/dev/null || true + run ifup $wlan_device || true +}
participants (1)
-
root