@@ -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} "
245245 echo -n " This is recommended for faster operation, and also in case there is not enough "
246- echo -n " space in your / partition. \n "
246+ echo -e " space in your / partition."
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
@@ -276,22 +276,20 @@ config_container_dir_mount () {
276276}
277277
278278start_container () {
279- STATUS=$( lxc query " /1.0/containers/${LXD_CONTAINER} /state" | \
280- jq --raw-output ' .status' )
279+ STATUS=$( lxc query " /1.0/containers/${LXD_CONTAINER} /state" | jq --raw-output ' .status' )
281280 if [ $STATUS = ' Stopped' ]; then
282281 # lxc start may give a failure code. It also may not, so we check
283282 # again in a bit.
284283 if ! lxc start $LXD_CONTAINER ; then
285- echo $LXD_CONTAINER_FAILURE_MSG
284+ echo -e $LXD_CONTAINER_FAILURE_MSG
286285 exit 1
287286 fi
288287 fi
289288
290289 # Unfortunately we need to check again. We check for Started this time
291290 # because the monitor may be hung with the container failing, which will
292291 # give us much different output
293- STATUS=$( lxc query " /1.0/containers/${LXD_CONTAINER} /state" | \
294- jq --raw-output ' .status' )
292+ STATUS=$( lxc query " /1.0/containers/${LXD_CONTAINER} /state" | jq --raw-output ' .status' )
295293 if [ " $STATUS " != ' Running' ]; then
296294 echo $LXD_CONTAINER_FAILURE_MSG
297295 exit 1
@@ -308,7 +306,7 @@ nonsdk_container_setup () {
308306 focal) ubports_repo_line=" deb http://repo2.ubports.com/ $container_ubuntu_version main" ;;
309307 esac
310308 if [ -n " $ubports_repo_line " ]; then
311- exec_container_root " echo '$ubports_repo_line ' >/etc/apt/sources.list.d/ubports.list"
309+ exec_container_root " echo '$ubports_repo_line ' > /etc/apt/sources.list.d/ubports.list"
312310 fi
313311
314312 # Skip multiarch setup if not crossbuilding
@@ -330,7 +328,7 @@ nonsdk_container_setup () {
330328 exec_container_root " sed -E \
331329 -e 's:(archive|security)\.ubuntu\.com/ubuntu/:ports.ubuntu.com/ubuntu-ports/:' \
332330 -e 's:^deb :deb [arch=${TARGET_ARCH} ] :' \
333- /etc/apt/sources.list >/etc/apt/sources.list.d/ports.list"
331+ /etc/apt/sources.list > /etc/apt/sources.list.d/ports.list"
334332 exec_container_root " sed -i -E \
335333 -e 's:^deb :deb [arch=${HOST_ARCH} ] :' \
336334 /etc/apt/sources.list"
@@ -341,7 +339,7 @@ nonsdk_container_setup () {
341339 -e 's:ports\.ubuntu\.com/ubuntu-ports/ ([a-z]+)-security :security.ubuntu.com/ubuntu/ \1-security :' \
342340 -e 's:ports\.ubuntu\.com/ubuntu-ports/ ([a-z-]+):archive.ubuntu.com/ubuntu/ \1 :' \
343341 -e 's:^deb :deb [arch=${TARGET_ARCH} ] :' \
344- /etc/apt/sources.list >/etc/apt/sources.list.d/non-ports.list"
342+ /etc/apt/sources.list > /etc/apt/sources.list.d/non-ports.list"
345343 exec_container_root " sed -i -E \
346344 -e 's:^deb :deb [arch=${HOST_ARCH} ] :' \
347345 /etc/apt/sources.list"
@@ -377,7 +375,7 @@ create_container () {
377375 exec_container_root " add-apt-repository -y ppa:ubports-developers/overlay"
378376 exec_container_root " add-apt-repository 'deb http://repo.ubports.com vivid main' >> /etc/apt/sources.list"
379377 fi
380- wget -qO - " https://repo.ubports.com/keyring.gpg" | exec_container_root ' cat >/etc/apt/trusted.gpg.d/ubports-keyring.gpg'
378+ wget -qO - " https://repo.ubports.com/keyring.gpg" | exec_container_root ' cat > /etc/apt/trusted.gpg.d/ubports-keyring.gpg'
381379 if ! echo " $LXD_IMAGE " | grep -q " ubuntu-sdk" ; then
382380 nonsdk_container_setup
383381 fi
@@ -593,7 +591,7 @@ install_foreign () {
593591 exec_container " mkdir -p foreign && cd foreign && apt-get download $dep && dpkg-deb -R $dep * tmp"
594592 exec_container " grep -vi '^multi' foreign/tmp/DEBIAN/control > foreign/tmp/DEBIAN/control.tmp"
595593 exec_container " mv foreign/tmp/DEBIAN/control.tmp foreign/tmp/DEBIAN/control"
596- exec_container " echo 'Multi-Arch: foreign' >> foreign/tmp/DEBIAN/control"
594+ exec_container " echo 'Multi-Arch: foreign' >> foreign/tmp/DEBIAN/control"
597595 exec_container " cd foreign && dpkg-deb -b tmp $dep *"
598596 exec_container_root " dpkg -i $SOURCE_PATH_CONTAINER /foreign/$dep *"
599597 exec_container " rm -r foreign/"
@@ -649,8 +647,8 @@ copy_build_to_container () {
649647 lxc file push $SCRIPT_DIR /$CREATE_REPO_SCRIPT $LXD_CONTAINER$SOURCE_REPOSITORY /
650648 exec_container $SOURCE_REPOSITORY /$CREATE_REPO_SCRIPT $SOURCE_REPOSITORY
651649
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"
650+ exec_container_root " echo 'deb [trusted=yes] file://$SOURCE_REPOSITORY / /' > /etc/apt/sources.list.d/localrepo.list"
651+ exec_container_root " printf 'Package: *\nPin: release o=local\nPin-Priority: 2000' > /etc/apt/preferences.d/localrepo.pref"
654652}
655653
656654clean () {
@@ -662,9 +660,7 @@ check_for_container_network() {
662660 NETWORK_UP=0
663661 for i in ` seq 1 10`
664662 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
663+ if lxc query " /1.0/containers/${LXD_CONTAINER} /state" | jq -e ' .network.eth0.addresses | any( .family == "inet" )' > /dev/null 2>&1 ; then
668664 NETWORK_UP=1
669665 break
670666 fi
@@ -765,7 +761,7 @@ deploy_to_device () {
765761 fi ;
766762
767763 # setup sudo on device
768- exec_device " printf '#\041/bin/sh\necho $DEVICE_PASSWORD ' >/tmp/askpass.sh"
764+ exec_device " printf '#\041/bin/sh\necho $DEVICE_PASSWORD ' > /tmp/askpass.sh"
769765 exec_device chmod +x /tmp/askpass.sh
770766
771767 # check password is correct
@@ -821,10 +817,11 @@ if stat --file-system $HOME | grep ecrypt ; then
821817fi
822818
823819if [ -e " /snap/bin/lxc" ]; then
820+ echo " Force privileged container"
824821 FORCE_PRIVILEGED=1
825822fi
826823
827- if ! which lxd > /dev/null ; then
824+ if ! which lxd > /dev/null 2>&1 ; then
828825 echo -e " ${POSITIVE_COLOR} $PROGRAM_NAME uses LXD to download dependencies and build.${NC} "
829826 echo -e -n " ${POSITIVE_COLOR} Would you like to install LXD? (y/n) ${NC} "
830827 read REPLY
@@ -835,8 +832,8 @@ if ! which lxd > /dev/null ; then
835832 sudo apt-get install -y lxd lxd-client
836833 setup_lxd
837834 ensure_lxd_subuid
838- newgrp lxd
839- sudo usermod -a -G lxd $( whoami)
835+ echo " Adding user to lxd group "
836+ sudo usermod -a -G lxd $( whoami)
840837 echo -e " ${ERROR_COLOR} LXD is now setup but will only work after you restart your computer.${NC} "
841838 exit 0
842839 else
@@ -912,7 +909,7 @@ while [ "$1" != "" ]; do
912909 * )
913910 display_help
914911 echo " "
915- echo -e " ${ERROR_COLOR} error : unknown option: $OPTION ${NC} "
912+ echo -e " ${ERROR_COLOR} Error : unknown option: $OPTION ${NC} "
916913 exit 1
917914 ;;
918915 esac
@@ -1148,7 +1145,7 @@ else
11481145 * )
11491146 display_help
11501147 echo " "
1151- echo -e " ${ERROR_COLOR} error : unknown command: $COMMAND ${NC} "
1148+ echo -e " ${ERROR_COLOR} Error : unknown command: $COMMAND ${NC} "
11521149 exit 1
11531150 ;;
11541151 esac
0 commit comments