| OLD | NEW |
| 1 #!/bin/bash | 1 #!/bin/bash |
| 2 | 2 |
| 3 # Copyright (c) 2011 The Chromium OS Authors. All rights reserved. | 3 # Copyright (c) 2011 The Chromium OS Authors. All rights reserved. |
| 4 # Use of this source code is governed by a BSD-style license that can be | 4 # Use of this source code is governed by a BSD-style license that can be |
| 5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
| 6 | 6 |
| 7 # Script to customize the root file system after packages have been installed. | 7 # Script to customize the root file system after packages have been installed. |
| 8 # | 8 # |
| 9 # NOTE: This is currently a dumping ground for for a bunch of hacks, some of | 9 # NOTE: This is currently a dumping ground for for a bunch of hacks, some of |
| 10 # which are to work around the fact that we are trying not to modify the base | 10 # which are to work around the fact that we are trying not to modify the base |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 echo "Error: Root FS does not exist? ($ROOT_FS_DIR)" | 61 echo "Error: Root FS does not exist? ($ROOT_FS_DIR)" |
| 62 exit 1 | 62 exit 1 |
| 63 fi | 63 fi |
| 64 | 64 |
| 65 # TODO: Is this still necessary? | 65 # TODO: Is this still necessary? |
| 66 sudo chmod 0755 "${ROOT_FS_DIR}/." | 66 sudo chmod 0755 "${ROOT_FS_DIR}/." |
| 67 | 67 |
| 68 # Set up a default dev user, update the password entry, and add to sudo. | 68 # Set up a default dev user, update the password entry, and add to sudo. |
| 69 # TODO: Make the default user conditional on building a dev image. | 69 # TODO: Make the default user conditional on building a dev image. |
| 70 DEV_USER="chronos" | 70 DEV_USER="chronos" |
| 71 SHELL="/bin/sh" | |
| 72 [[ -x "${ROOT_FS_DIR}/usr/local/bin/bash" ]] && SHELL="/usr/local/bin/bash" | |
| 73 [[ -x "${ROOT_FS_DIR}/bin/bash" ]] && SHELL="/bin/bash" | |
| 74 | 71 |
| 75 # Determine what password to use for the default user. | 72 # Determine what password to use for the default user. |
| 76 CRYPTED_PASSWD_FILE="${SCRIPTS_DIR}/shared_user_passwd.txt" | 73 CRYPTED_PASSWD_FILE="${SCRIPTS_DIR}/shared_user_passwd.txt" |
| 77 if [ -f $CRYPTED_PASSWD_FILE ]; then | 74 if [ -f $CRYPTED_PASSWD_FILE ]; then |
| 78 echo "Using password from $CRYPTED_PASSWD_FILE" | 75 echo "Using password from $CRYPTED_PASSWD_FILE" |
| 79 CRYPTED_PASSWD=$(cat $CRYPTED_PASSWD_FILE) | 76 CRYPTED_PASSWD=$(cat $CRYPTED_PASSWD_FILE) |
| 80 else | 77 else |
| 81 # Use an invalid password so ensure pam_unix failure. | 78 # Use an invalid password so ensure pam_unix failure. |
| 82 echo "Using invalid password." | 79 echo "Using invalid password." |
| 83 CRYPTED_PASSWD='*' | 80 CRYPTED_PASSWD='*' |
| 84 fi | 81 fi |
| 85 # Replace the DEV_USER passwd entry with one that sets the proper shell and | 82 # Replace the DEV_USER passwd entry with one that sets the proper shell and |
| 86 # specifies that the passwd should come from /etc/shadow. | 83 # specifies that the passwd should come from /etc/shadow. |
| 87 sudo sed -i "{ s|${DEV_USER}:\*:\(.*\):.*|${DEV_USER}:x:\1:${SHELL}| }" \ | 84 sudo sed -i "{ s|${DEV_USER}:\*:\(.*\):.*|${DEV_USER}:x:\1:/bin/sh| }" \ |
| 88 "${ROOT_FS_DIR}/etc/passwd" | 85 "${ROOT_FS_DIR}/etc/passwd" |
| 89 echo "${DEV_USER}:${CRYPTED_PASSWD}:14500:0:99999::::" \ | 86 echo "${DEV_USER}:${CRYPTED_PASSWD}:14500:0:99999::::" \ |
| 90 | sudo dd of="${ROOT_FS_DIR}/etc/shadow" conv=notrunc oflag=append | 87 | sudo dd of="${ROOT_FS_DIR}/etc/shadow" conv=notrunc oflag=append |
| 91 | 88 |
| 92 # sudo and vt2 are important for system debugging both in developer mode | 89 # sudo and vt2 are important for system debugging both in developer mode |
| 93 # and during development. These two stanzas allow sudo and login auth | 90 # and during development. These two stanzas allow sudo and login auth |
| 94 # as user chronos under the following conditions: | 91 # as user chronos under the following conditions: |
| 95 # | 92 # |
| 96 # 1. password-less access: | 93 # 1. password-less access: |
| 97 # - system in developer mode | 94 # - system in developer mode |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 198 QEMU="qemu-i386" | 195 QEMU="qemu-i386" |
| 199 ;; | 196 ;; |
| 200 *) | 197 *) |
| 201 error "Unable to determine ARCH from toolchain: $CHOST" | 198 error "Unable to determine ARCH from toolchain: $CHOST" |
| 202 exit 1 | 199 exit 1 |
| 203 esac | 200 esac |
| 204 cp "/usr/bin/${QEMU}" "${ROOT_FS_DIR}/tmp" | 201 cp "/usr/bin/${QEMU}" "${ROOT_FS_DIR}/tmp" |
| 205 sudo mkdir -p "${ROOT_FS_DIR}/usr/share/fontconfig" | 202 sudo mkdir -p "${ROOT_FS_DIR}/usr/share/fontconfig" |
| 206 sudo chroot "${ROOT_FS_DIR}" "/tmp/${QEMU}" /usr/bin/fc-cache -f | 203 sudo chroot "${ROOT_FS_DIR}" "/tmp/${QEMU}" /usr/bin/fc-cache -f |
| 207 rm "${ROOT_FS_DIR}/tmp/${QEMU}" | 204 rm "${ROOT_FS_DIR}/tmp/${QEMU}" |
| OLD | NEW |