Chris Masone | fdda89f | 2010-02-08 13:11:31 -0800 | [diff] [blame] | 1 | #!/bin/bash |
David McMahon | b6fb706 | 2010-02-09 11:44:09 -0800 | [diff] [blame] | 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 |
| 4 | # found in the LICENSE file. |
Chris Masone | fdda89f | 2010-02-08 13:11:31 -0800 | [diff] [blame] | 5 | set -e |
| 6 | |
Greg Spencer | 798d75f | 2011-02-01 22:04:49 -0800 | [diff] [blame] | 7 | if [ -z $1 ]; then |
David McMahon | 9cc8f95 | 2010-04-27 13:49:06 -0700 | [diff] [blame] | 8 | echo "Usage: $0 localaccount_username [chroot_path]" |
Chris Masone | fdda89f | 2010-02-08 13:11:31 -0800 | [diff] [blame] | 9 | exit 1 |
| 10 | fi |
| 11 | |
David McMahon | 9cc8f95 | 2010-04-27 13:49:06 -0700 | [diff] [blame] | 12 | # Default chroot_path to its standard location |
| 13 | chroot_path=${2:-"../../chroot"} |
| 14 | |
Chris Masone | fdda89f | 2010-02-08 13:11:31 -0800 | [diff] [blame] | 15 | echo "Enabling local account $1@gmail.com." |
Mandeep Singh Baines | 7c5fa53 | 2010-03-01 20:06:08 -0800 | [diff] [blame] | 16 | |
| 17 | # Add CHROMEOS_LOCAL_ACCOUNT var to /etc/make.conf.user |
David McMahon | 9cc8f95 | 2010-04-27 13:49:06 -0700 | [diff] [blame] | 18 | echo "Setting CHROMEOS_LOCAL_ACCOUNT in $chroot_path/etc/make.conf.user..." |
Mandeep Singh Baines | 7c5fa53 | 2010-03-01 20:06:08 -0800 | [diff] [blame] | 19 | VAR_NAME=CHROMEOS_LOCAL_ACCOUNT |
David McMahon | 9cc8f95 | 2010-04-27 13:49:06 -0700 | [diff] [blame] | 20 | if grep -q ${VAR_NAME} $chroot_path/etc/make.conf.user; then |
Mandeep Singh Baines | 7c5fa53 | 2010-03-01 20:06:08 -0800 | [diff] [blame] | 21 | regex="s/${VAR_NAME}=.*/${VAR_NAME}=$1@gmail.com/" |
David McMahon | 9cc8f95 | 2010-04-27 13:49:06 -0700 | [diff] [blame] | 22 | sudo sed -i -e "${regex}" $chroot_path/etc/make.conf.user |
Mandeep Singh Baines | 7c5fa53 | 2010-03-01 20:06:08 -0800 | [diff] [blame] | 23 | else |
David McMahon | 9cc8f95 | 2010-04-27 13:49:06 -0700 | [diff] [blame] | 24 | sudo sh -c "echo ""${VAR_NAME}=$1@gmail.com"" >> \ |
| 25 | $chroot_path/etc/make.conf.user" |
Mandeep Singh Baines | 7c5fa53 | 2010-03-01 20:06:08 -0800 | [diff] [blame] | 26 | fi |