@@ -162,7 +162,7 @@ check_lxd_accessible () {
162162 # /bin/lxd is replaced with a script which tells you to install the lxd snap
163163 # on later versions of Ubuntu.
164164 LXD=` which lxd`
165- if (grep ' snap install lxd' " $LXD " > /dev/null) && [ ! -f /snap/bin/lxd ] ; then
165+ if (grep ' snap install lxd' " $LXD " > /dev/null) && [ ! -f /snap/bin/lxd ] ; then
166166 $LXD
167167 exit 1
168168 fi
@@ -231,24 +231,24 @@ setup_lxd () {
231231 echo " this for you."
232232 echo " Press Enter to start"
233233 read KEY
234- unset $ KEY
234+ unset KEY
235235 # Ubuntu 16.04 specific workaround to set up
236236 sudo dpkg-reconfigure -p medium lxd
237237 fi
238238
239239 if [ -n " $ENCRYPTED_HOME " ] ; then
240- echo -e -n " ${ERROR_COLOR} Your home folder is encrypted. $PROGRAM_NAME will use priviledged "
240+ echo -e -n " ${ERROR_COLOR} Your home folder is encrypted. $PROGRAM_NAME will use privileged "
241241 echo -e -n " LXD containers and the default storage backend (slower).\n${NC} "
242242 sudo lxd init --auto
243243 else
244244 echo -e -n " ${POSITIVE_COLOR} Would you like to setup LXD with ZFS in your home directory? (y/n) \n${NC} "
245- echo -n " This is recommended for faster operation, and also in case there is not enough "
246- echo -n " space in your / partition. \n"
245+ echo -e - n " This is recommended for faster operation, and also in case there is not enough "
246+ echo -e - n " space in your / partition. \n"
247247 read REPLY
248248 echo
249249 if [ " $REPLY " = y ]
250250 then
251- if ! which zpool > /dev/null ; then
251+ if ! which zpool > /dev/null 2>&1 ; then
252252 echo -e " ${POSITIVE_COLOR} Installing ZFS.${NC} "
253253 sudo apt-get install -y zfsutils-linux
254254 fi
@@ -261,6 +261,7 @@ setup_lxd () {
261261 # add automatic mount of zfs pool upon boot
262262 echo " zpool import -c /etc/zfs/zpool.cache -aN" | sudo tee /etc/rc.local
263263 else
264+ echo " sudo lxd init --auto"
264265 sudo lxd init --auto
265266 fi
266267 fi
@@ -276,22 +277,20 @@ config_container_dir_mount () {
276277}
277278
278279start_container () {
279- STATUS=$( lxc query " /1.0/containers/${LXD_CONTAINER} /state" | \
280- jq --raw-output ' .status' )
280+ STATUS=$( lxc query " /1.0/containers/${LXD_CONTAINER} /state" | jq --raw-output ' .status' )
281281 if [ $STATUS = ' Stopped' ]; then
282282 # lxc start may give a failure code. It also may not, so we check
283283 # again in a bit.
284284 if ! lxc start $LXD_CONTAINER ; then
285- echo $LXD_CONTAINER_FAILURE_MSG
285+ echo -e $LXD_CONTAINER_FAILURE_MSG
286286 exit 1
287287 fi
288288 fi
289289
290290 # Unfortunately we need to check again. We check for Started this time
291291 # because the monitor may be hung with the container failing, which will
292292 # give us much different output
293- STATUS=$( lxc query " /1.0/containers/${LXD_CONTAINER} /state" | \
294- jq --raw-output ' .status' )
293+ STATUS=$( lxc query " /1.0/containers/${LXD_CONTAINER} /state" | jq --raw-output ' .status' )
295294 if [ " $STATUS " != ' Running' ]; then
296295 echo $LXD_CONTAINER_FAILURE_MSG
297296 exit 1
@@ -308,7 +307,7 @@ nonsdk_container_setup () {
308307 focal) ubports_repo_line=" deb http://repo2.ubports.com/ $container_ubuntu_version main" ;;
309308 esac
310309 if [ -n " $ubports_repo_line " ]; then
311- exec_container_root " echo '$ubports_repo_line ' >/etc/apt/sources.list.d/ubports.list"
310+ exec_container_root " echo '$ubports_repo_line ' > /etc/apt/sources.list.d/ubports.list"
312311 fi
313312
314313 # Skip multiarch setup if not crossbuilding
@@ -330,7 +329,7 @@ nonsdk_container_setup () {
330329 exec_container_root " sed -E \
331330 -e 's:(archive|security)\.ubuntu\.com/ubuntu/:ports.ubuntu.com/ubuntu-ports/:' \
332331 -e 's:^deb :deb [arch=${TARGET_ARCH} ] :' \
333- /etc/apt/sources.list >/etc/apt/sources.list.d/ports.list"
332+ /etc/apt/sources.list > /etc/apt/sources.list.d/ports.list"
334333 exec_container_root " sed -i -E \
335334 -e 's:^deb :deb [arch=${HOST_ARCH} ] :' \
336335 /etc/apt/sources.list"
@@ -341,7 +340,7 @@ nonsdk_container_setup () {
341340 -e 's:ports\.ubuntu\.com/ubuntu-ports/ ([a-z]+)-security :security.ubuntu.com/ubuntu/ \1-security :' \
342341 -e 's:ports\.ubuntu\.com/ubuntu-ports/ ([a-z-]+):archive.ubuntu.com/ubuntu/ \1 :' \
343342 -e 's:^deb :deb [arch=${TARGET_ARCH} ] :' \
344- /etc/apt/sources.list >/etc/apt/sources.list.d/non-ports.list"
343+ /etc/apt/sources.list > /etc/apt/sources.list.d/non-ports.list"
345344 exec_container_root " sed -i -E \
346345 -e 's:^deb :deb [arch=${HOST_ARCH} ] :' \
347346 /etc/apt/sources.list"
@@ -377,7 +376,7 @@ create_container () {
377376 exec_container_root " add-apt-repository -y ppa:ubports-developers/overlay"
378377 exec_container_root " add-apt-repository 'deb http://repo.ubports.com vivid main' >> /etc/apt/sources.list"
379378 fi
380- wget -qO - " https://repo.ubports.com/keyring.gpg" | exec_container_root ' cat >/etc/apt/trusted.gpg.d/ubports-keyring.gpg'
379+ wget -qO - " https://repo.ubports.com/keyring.gpg" | exec_container_root ' cat > /etc/apt/trusted.gpg.d/ubports-keyring.gpg'
381380 if ! echo " $LXD_IMAGE " | grep -q " ubuntu-sdk" ; then
382381 nonsdk_container_setup
383382 fi
@@ -593,7 +592,7 @@ install_foreign () {
593592 exec_container " mkdir -p foreign && cd foreign && apt-get download $dep && dpkg-deb -R $dep * tmp"
594593 exec_container " grep -vi '^multi' foreign/tmp/DEBIAN/control > foreign/tmp/DEBIAN/control.tmp"
595594 exec_container " mv foreign/tmp/DEBIAN/control.tmp foreign/tmp/DEBIAN/control"
596- exec_container " echo 'Multi-Arch: foreign' >> foreign/tmp/DEBIAN/control"
595+ exec_container " echo 'Multi-Arch: foreign' >> foreign/tmp/DEBIAN/control"
597596 exec_container " cd foreign && dpkg-deb -b tmp $dep *"
598597 exec_container_root " dpkg -i $SOURCE_PATH_CONTAINER /foreign/$dep *"
599598 exec_container " rm -r foreign/"
@@ -649,8 +648,8 @@ copy_build_to_container () {
649648 lxc file push $SCRIPT_DIR /$CREATE_REPO_SCRIPT $LXD_CONTAINER$SOURCE_REPOSITORY /
650649 exec_container $SOURCE_REPOSITORY /$CREATE_REPO_SCRIPT $SOURCE_REPOSITORY
651650
652- exec_container_root " echo 'deb [trusted=yes] file://$SOURCE_REPOSITORY / /' >/etc/apt/sources.list.d/localrepo.list"
653- exec_container_root " printf 'Package: *\nPin: release o=local\nPin-Priority: 2000' >/etc/apt/preferences.d/localrepo.pref"
651+ exec_container_root " echo 'deb [trusted=yes] file://$SOURCE_REPOSITORY / /' > /etc/apt/sources.list.d/localrepo.list"
652+ exec_container_root " printf 'Package: *\nPin: release o=local\nPin-Priority: 2000' > /etc/apt/preferences.d/localrepo.pref"
654653}
655654
656655clean () {
@@ -662,9 +661,7 @@ check_for_container_network() {
662661 NETWORK_UP=0
663662 for i in ` seq 1 10`
664663 do
665- if lxc query " /1.0/containers/${LXD_CONTAINER} /state" | \
666- jq -e ' .network.eth0.addresses | any( .family == "inet" )' \
667- > /dev/null 2>&1 ; then
664+ if lxc query " /1.0/containers/${LXD_CONTAINER} /state" | jq -e ' .network.eth0.addresses | any( .family == "inet" )' > /dev/null 2>&1 ; then
668665 NETWORK_UP=1
669666 break
670667 fi
@@ -765,7 +762,7 @@ deploy_to_device () {
765762 fi ;
766763
767764 # setup sudo on device
768- exec_device " printf '#\041/bin/sh\necho $DEVICE_PASSWORD ' >/tmp/askpass.sh"
765+ exec_device " printf '#\041/bin/sh\necho $DEVICE_PASSWORD ' > /tmp/askpass.sh"
769766 exec_device chmod +x /tmp/askpass.sh
770767
771768 # check password is correct
@@ -821,10 +818,11 @@ if stat --file-system $HOME | grep ecrypt ; then
821818fi
822819
823820if [ -e " /snap/bin/lxc" ]; then
821+ echo " Force privileged container"
824822 FORCE_PRIVILEGED=1
825823fi
826824
827- if ! which lxd > /dev/null ; then
825+ if ! which lxd > /dev/null 2>&1 ; then
828826 echo -e " ${POSITIVE_COLOR} $PROGRAM_NAME uses LXD to download dependencies and build.${NC} "
829827 echo -e -n " ${POSITIVE_COLOR} Would you like to install LXD? (y/n) ${NC} "
830828 read REPLY
@@ -835,8 +833,8 @@ if ! which lxd > /dev/null ; then
835833 sudo apt-get install -y lxd lxd-client
836834 setup_lxd
837835 ensure_lxd_subuid
838- newgrp lxd
839- sudo usermod -a -G lxd $( whoami)
836+ echo " Adding user to lxd group "
837+ sudo usermod -a -G lxd $( whoami)
840838 echo -e " ${ERROR_COLOR} LXD is now setup but will only work after you restart your computer.${NC} "
841839 exit 0
842840 else
@@ -912,7 +910,7 @@ while [ "$1" != "" ]; do
912910 * )
913911 display_help
914912 echo " "
915- echo -e " ${ERROR_COLOR} error : unknown option: $OPTION ${NC} "
913+ echo -e " ${ERROR_COLOR} Error : unknown option: $OPTION ${NC} "
916914 exit 1
917915 ;;
918916 esac
@@ -1148,7 +1146,7 @@ else
11481146 * )
11491147 display_help
11501148 echo " "
1151- echo -e " ${ERROR_COLOR} error : unknown command: $COMMAND ${NC} "
1149+ echo -e " ${ERROR_COLOR} Error : unknown command: $COMMAND ${NC} "
11521150 exit 1
11531151 ;;
11541152 esac
0 commit comments