| OLD | NEW |
| 1 #!/bin/bash | 1 #!/bin/bash |
| 2 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | 2 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 set -e | 5 set -e |
| 6 | 6 |
| 7 if [ -z $1 ] | 7 if [ -z $1 ] |
| 8 then | 8 then |
| 9 echo "Usage: $0 localaccount_username [chroot_path]" | 9 echo "Usage: $0 localaccount_username [chroot_path]" |
| 10 exit 1 | 10 exit 1 |
| 11 fi | 11 fi |
| 12 | 12 |
| 13 # Default chroot_path to its standard location | 13 # Default chroot_path to its standard location |
| 14 chroot_path=${2:-"../../chroot"} | 14 chroot_path=${2:-"../../chroot"} |
| 15 | 15 |
| 16 echo "Enabling local account $1@gmail.com." | 16 echo "Enabling local account $1@gmail.com." |
| 17 echo "Remove these files to disable:" | |
| 18 | |
| 19 for namespace in pam_google pam_offline | |
| 20 do | |
| 21 file=../platform/$namespace/pam_localaccount.h | |
| 22 [ "$namespace" = pam_google ] && namespace=chromeos_pam | |
| 23 | |
| 24 echo $file | |
| 25 | |
| 26 cat <<EOF > $file | |
| 27 // local username for Chrome OS pam | |
| 28 // This file is auto-generated by enable_localaccount.sh | |
| 29 | |
| 30 #ifndef CHROMEOS_PAM_LOCALACCOUNT_H_ | |
| 31 #define CHROMEOS_PAM_LOCALACCOUNT_H_ | |
| 32 | |
| 33 namespace $namespace { | |
| 34 const char kLocalAccount[] = "$1@gmail.com"; | |
| 35 } | |
| 36 | |
| 37 #endif // CHROMEOS_PAM_LOCALACCOUNT_H_ | |
| 38 EOF | |
| 39 done | |
| 40 | 17 |
| 41 # Add CHROMEOS_LOCAL_ACCOUNT var to /etc/make.conf.user | 18 # Add CHROMEOS_LOCAL_ACCOUNT var to /etc/make.conf.user |
| 42 echo "Setting CHROMEOS_LOCAL_ACCOUNT in $chroot_path/etc/make.conf.user..." | 19 echo "Setting CHROMEOS_LOCAL_ACCOUNT in $chroot_path/etc/make.conf.user..." |
| 43 VAR_NAME=CHROMEOS_LOCAL_ACCOUNT | 20 VAR_NAME=CHROMEOS_LOCAL_ACCOUNT |
| 44 if grep -q ${VAR_NAME} $chroot_path/etc/make.conf.user; then | 21 if grep -q ${VAR_NAME} $chroot_path/etc/make.conf.user; then |
| 45 regex="s/${VAR_NAME}=.*/${VAR_NAME}=$1@gmail.com/" | 22 regex="s/${VAR_NAME}=.*/${VAR_NAME}=$1@gmail.com/" |
| 46 sudo sed -i -e "${regex}" $chroot_path/etc/make.conf.user | 23 sudo sed -i -e "${regex}" $chroot_path/etc/make.conf.user |
| 47 else | 24 else |
| 48 sudo sh -c "echo ""${VAR_NAME}=$1@gmail.com"" >> \ | 25 sudo sh -c "echo ""${VAR_NAME}=$1@gmail.com"" >> \ |
| 49 $chroot_path/etc/make.conf.user" | 26 $chroot_path/etc/make.conf.user" |
| 50 fi | 27 fi |
| OLD | NEW |