blob: 2232551977f80791347ad047b482e7ab27ff59f3 [file] [log] [blame]
Chris Masonefdda89f2010-02-08 13:11:31 -08001#!/bin/bash
David McMahonb6fb7062010-02-09 11:44:09 -08002# 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 Masonefdda89f2010-02-08 13:11:31 -08005set -e
6
Greg Spencer798d75f2011-02-01 22:04:49 -08007if [ -z $1 ]; then
David McMahon9cc8f952010-04-27 13:49:06 -07008 echo "Usage: $0 localaccount_username [chroot_path]"
Chris Masonefdda89f2010-02-08 13:11:31 -08009 exit 1
10fi
11
David McMahon9cc8f952010-04-27 13:49:06 -070012# Default chroot_path to its standard location
13chroot_path=${2:-"../../chroot"}
14
Chris Masonefdda89f2010-02-08 13:11:31 -080015echo "Enabling local account $1@gmail.com."
Mandeep Singh Baines7c5fa532010-03-01 20:06:08 -080016
17# Add CHROMEOS_LOCAL_ACCOUNT var to /etc/make.conf.user
David McMahon9cc8f952010-04-27 13:49:06 -070018echo "Setting CHROMEOS_LOCAL_ACCOUNT in $chroot_path/etc/make.conf.user..."
Mandeep Singh Baines7c5fa532010-03-01 20:06:08 -080019VAR_NAME=CHROMEOS_LOCAL_ACCOUNT
David McMahon9cc8f952010-04-27 13:49:06 -070020if grep -q ${VAR_NAME} $chroot_path/etc/make.conf.user; then
Mandeep Singh Baines7c5fa532010-03-01 20:06:08 -080021 regex="s/${VAR_NAME}=.*/${VAR_NAME}=$1@gmail.com/"
David McMahon9cc8f952010-04-27 13:49:06 -070022 sudo sed -i -e "${regex}" $chroot_path/etc/make.conf.user
Mandeep Singh Baines7c5fa532010-03-01 20:06:08 -080023else
David McMahon9cc8f952010-04-27 13:49:06 -070024 sudo sh -c "echo ""${VAR_NAME}=$1@gmail.com"" >> \
25 $chroot_path/etc/make.conf.user"
Mandeep Singh Baines7c5fa532010-03-01 20:06:08 -080026fi