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" | 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 |
| 14 chroot_path=${2:-"../../chroot"} |
| 15 |
13 echo "Enabling local account $1@gmail.com." | 16 echo "Enabling local account $1@gmail.com." |
14 echo "Remove these files to disable:" | 17 echo "Remove these files to disable:" |
15 | 18 |
16 for namespace in pam_google pam_offline | 19 for namespace in pam_google pam_offline |
17 do | 20 do |
18 file=../platform/$namespace/pam_localaccount.h | 21 file=../platform/$namespace/pam_localaccount.h |
19 [ "$namespace" = pam_google ] && namespace=chromeos_pam | 22 [ "$namespace" = pam_google ] && namespace=chromeos_pam |
20 | 23 |
21 echo $file | 24 echo $file |
22 | 25 |
23 cat <<EOF > $file | 26 cat <<EOF > $file |
24 // local username for Chrome OS pam | 27 // local username for Chrome OS pam |
25 // This file is auto-generated by enable_localaccount.sh | 28 // This file is auto-generated by enable_localaccount.sh |
26 | 29 |
27 #ifndef CHROMEOS_PAM_LOCALACCOUNT_H_ | 30 #ifndef CHROMEOS_PAM_LOCALACCOUNT_H_ |
28 #define CHROMEOS_PAM_LOCALACCOUNT_H_ | 31 #define CHROMEOS_PAM_LOCALACCOUNT_H_ |
29 | 32 |
30 namespace $namespace { | 33 namespace $namespace { |
31 const char kLocalAccount[] = "$1@gmail.com"; | 34 const char kLocalAccount[] = "$1@gmail.com"; |
32 } | 35 } |
33 | 36 |
34 #endif // CHROMEOS_PAM_LOCALACCOUNT_H_ | 37 #endif // CHROMEOS_PAM_LOCALACCOUNT_H_ |
35 EOF | 38 EOF |
36 done | 39 done |
37 | 40 |
38 # Add CHROMEOS_LOCAL_ACCOUNT var to /etc/make.conf.user | 41 # Add CHROMEOS_LOCAL_ACCOUNT var to /etc/make.conf.user |
| 42 echo "Setting CHROMEOS_LOCAL_ACCOUNT in $chroot_path/etc/make.conf.user..." |
39 VAR_NAME=CHROMEOS_LOCAL_ACCOUNT | 43 VAR_NAME=CHROMEOS_LOCAL_ACCOUNT |
40 if grep -q ${VAR_NAME} /etc/make.conf.user; then | 44 if grep -q ${VAR_NAME} $chroot_path/etc/make.conf.user; then |
41 regex="s/${VAR_NAME}=.*/${VAR_NAME}=$1@gmail.com/" | 45 regex="s/${VAR_NAME}=.*/${VAR_NAME}=$1@gmail.com/" |
42 sudo sed -i -e "${regex}" /etc/make.conf.user | 46 sudo sed -i -e "${regex}" $chroot_path/etc/make.conf.user |
43 else | 47 else |
44 sudo sh -c "echo ""${VAR_NAME}=$1@gmail.com"" >> /etc/make.conf.user" | 48 sudo sh -c "echo ""${VAR_NAME}=$1@gmail.com"" >> \ |
| 49 $chroot_path/etc/make.conf.user" |
45 fi | 50 fi |
OLD | NEW |