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 ]; then |
8 then | |
9 echo "Usage: $0 localaccount_username [chroot_path]" | 8 echo "Usage: $0 localaccount_username [chroot_path]" |
10 exit 1 | 9 exit 1 |
11 fi | 10 fi |
12 | 11 |
13 # Default chroot_path to its standard location | 12 # Default chroot_path to its standard location |
14 chroot_path=${2:-"../../chroot"} | 13 chroot_path=${2:-"../../chroot"} |
15 | 14 |
16 echo "Enabling local account $1@gmail.com." | 15 echo "Enabling local account $1@gmail.com." |
17 | 16 |
18 # Add CHROMEOS_LOCAL_ACCOUNT var to /etc/make.conf.user | 17 # Add CHROMEOS_LOCAL_ACCOUNT var to /etc/make.conf.user |
19 echo "Setting CHROMEOS_LOCAL_ACCOUNT in $chroot_path/etc/make.conf.user..." | 18 echo "Setting CHROMEOS_LOCAL_ACCOUNT in $chroot_path/etc/make.conf.user..." |
20 VAR_NAME=CHROMEOS_LOCAL_ACCOUNT | 19 VAR_NAME=CHROMEOS_LOCAL_ACCOUNT |
21 if grep -q ${VAR_NAME} $chroot_path/etc/make.conf.user; then | 20 if grep -q ${VAR_NAME} $chroot_path/etc/make.conf.user; then |
22 regex="s/${VAR_NAME}=.*/${VAR_NAME}=$1@gmail.com/" | 21 regex="s/${VAR_NAME}=.*/${VAR_NAME}=$1@gmail.com/" |
23 sudo sed -i -e "${regex}" $chroot_path/etc/make.conf.user | 22 sudo sed -i -e "${regex}" $chroot_path/etc/make.conf.user |
24 else | 23 else |
25 sudo sh -c "echo ""${VAR_NAME}=$1@gmail.com"" >> \ | 24 sudo sh -c "echo ""${VAR_NAME}=$1@gmail.com"" >> \ |
26 $chroot_path/etc/make.conf.user" | 25 $chroot_path/etc/make.conf.user" |
27 fi | 26 fi |
OLD | NEW |