Skip to content

Commit

Permalink
Merge pull request #1969 from alistair23/alistair/sudo
Browse files Browse the repository at this point in the history
Allow running mycroft on embedded devices without sudo
  • Loading branch information
forslund committed Jan 28, 2019
2 parents 9ef9550 + 50463d2 commit a407691
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
10 changes: 5 additions & 5 deletions dev_setup.sh
Expand Up @@ -194,8 +194,8 @@ fi" > ~/.profile_mycroft
if [[ ! -d /opt/mycroft/skills ]] ; then
echo "This script will create that folder for you. This requires sudo"
echo "permission and might ask you for a password..."
sudo mkdir -p /opt/mycroft/skills
sudo chown -R $USER:$USER /opt/mycroft
$SUDO mkdir -p /opt/mycroft/skills
$SUDO chown -R $USER:$USER /opt/mycroft
echo "Created!"
fi
if [[ ! -d skills ]] ; then
Expand Down Expand Up @@ -235,7 +235,7 @@ function install_deps() {
echo "Installing packages..."
if found_exe sudo ; then
SUDO=sudo
else
elif [ "${opt_allowroot}" != true ]; then
echo "This script requires \"sudo\" to install system packages. Please install it, then re-run this script."
exit 1
fi
Expand Down Expand Up @@ -416,9 +416,9 @@ if [[ ! -w /var/log/mycroft/ ]] ; then
# Creating and setting permissions
echo "Creating /var/log/mycroft/ directory"
if [[ ! -d /var/log/mycroft/ ]] ; then
sudo mkdir /var/log/mycroft/
$SUDO mkdir /var/log/mycroft/
fi
sudo chmod 777 /var/log/mycroft/
$SUDO chmod 777 /var/log/mycroft/
fi

#Store a fingerprint of setup
Expand Down
15 changes: 12 additions & 3 deletions scripts/prepare-msm.sh
Expand Up @@ -31,18 +31,27 @@ DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
setup_user=$USER
setup_group=$( id -gn $USER )

function found_exe() {
hash "$1" 2>/dev/null
}

if found_exe sudo ; then
# The main checks happen in dev_setup.sh, don't error here if we don't have sudo
SUDO=sudo
fi

# change ownership of ${mycroft_root_dir} to ${setup_user } recursively
function change_ownership {
echo "Changing ownership of" ${mycroft_root_dir} "to user:" ${setup_user} "with group:" ${setup_group}
sudo chown -Rvf ${setup_user}:${setup_group} ${mycroft_root_dir}
$SUDO chown -Rvf ${setup_user}:${setup_group} ${mycroft_root_dir}
}


if [[ ${IS_TRAVIS} != true ]] ; then
if [ ! -d ${skills_dir} ] ; then
echo "Create ${skills_dir}"
sudo mkdir -p ${skills_dir}
change_ownership
$SUDO mkdir -p ${skills_dir}
change_ownership
fi

if [ ! -w ${SKILLS_DIR} ] ; then
Expand Down

0 comments on commit a407691

Please sign in to comment.