Skip to content
This repository was archived by the owner on Sep 8, 2024. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 21 additions & 5 deletions scripts/prepare-msm.sh
Original file line number Diff line number Diff line change
@@ -1,18 +1,34 @@
#!/usr/bin/env bash

SKILLS_DIR='/opt/mycroft/skills'
mycroft_root_dir='/opt/mycroft'
skills_dir="${mycroft_root_dir}"/skills
# exit on any error
set -Ee
chmod +x msm/msm

# Determine which user is running this script
setup_user=$USER

# 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_user}
sudo chown -Rvf ${setup_user}:${setup_user} ${mycroft_root_dir}
}


if [[ ${IS_TRAVIS} != true ]]; then
if [ ! -d ${SKILLS_DIR} ]; then
if [ ! -d ${skills_dir} ]; then
echo "Create /opt/mycroft/skills"
sudo mkdir -p ${SKILLS_DIR}
sudo mkdir -p ${skills_dir}
change_ownership
fi

if [ ! -w ${SKILLS_DIR} ]; then
echo "Changing ownership of /opt/mycroft/skills"
sudo chown $USER:$USER ${SKILLS_DIR}
change_ownership
fi
fi

# fix ownership of ${mycroft_root_dir} if it is not owned by the ${setup_user}
if [[ `stat -c "%U:%G" /opt/mycroft` != "${setup_user}:${setup_user}" ]]; then
change_ownership
fi