Merge "Only run chmod/chown for local files"
This commit is contained in:
commit
b305eeea1b
52
functions
52
functions
@ -1160,6 +1160,51 @@ function service_check() {
|
||||
fi
|
||||
}
|
||||
|
||||
# Returns true if the directory is on a filesystem mounted via NFS.
|
||||
function is_nfs_directory() {
|
||||
local mount_type=`stat -f -L -c %T $1`
|
||||
test "$mount_type" == "nfs"
|
||||
}
|
||||
|
||||
# Only run the command if the target file (the last arg) is not on an
|
||||
# NFS filesystem.
|
||||
function _safe_permission_operation() {
|
||||
local args=( $@ )
|
||||
local last
|
||||
local sudo_cmd
|
||||
local dir_to_check
|
||||
|
||||
let last="${#args[*]} - 1"
|
||||
|
||||
dir_to_check=${args[$last]}
|
||||
if [ ! -d "$dir_to_check" ]; then
|
||||
dir_to_check=`dirname "$dir_to_check"`
|
||||
fi
|
||||
|
||||
if is_nfs_directory "$dir_to_check" ; then
|
||||
return 0
|
||||
fi
|
||||
|
||||
if [[ $TRACK_DEPENDS = True ]]; then
|
||||
sudo_cmd="env"
|
||||
else
|
||||
sudo_cmd="sudo"
|
||||
fi
|
||||
|
||||
$sudo_cmd $@
|
||||
}
|
||||
|
||||
# Only change ownership of a file or directory if it is not on an NFS
|
||||
# filesystem.
|
||||
function safe_chown() {
|
||||
_safe_permission_operation chown $@
|
||||
}
|
||||
|
||||
# Only change permissions of a file or directory if it is not on an
|
||||
# NFS filesystem.
|
||||
function safe_chmod() {
|
||||
_safe_permission_operation chmod $@
|
||||
}
|
||||
|
||||
# ``pip install -e`` the package, which processes the dependencies
|
||||
# using pip before running `setup.py develop`
|
||||
@ -1167,11 +1212,6 @@ function service_check() {
|
||||
# setup_develop directory
|
||||
function setup_develop() {
|
||||
local project_dir=$1
|
||||
if [[ $TRACK_DEPENDS = True ]]; then
|
||||
SUDO_CMD="env"
|
||||
else
|
||||
SUDO_CMD="sudo"
|
||||
fi
|
||||
|
||||
echo "cd $REQUIREMENTS_DIR; $SUDO_CMD python update.py $project_dir"
|
||||
|
||||
@ -1183,7 +1223,7 @@ function setup_develop() {
|
||||
|
||||
pip_install -e $project_dir
|
||||
# ensure that further actions can do things like setup.py sdist
|
||||
$SUDO_CMD chown -R $STACK_USER $1/*.egg-info
|
||||
safe_chown -R $STACK_USER $1/*.egg-info
|
||||
}
|
||||
|
||||
|
||||
|
10
stack.sh
10
stack.sh
@ -203,7 +203,7 @@ if [[ $EUID -eq 0 ]]; then
|
||||
echo "Copying files to $STACK_USER user"
|
||||
STACK_DIR="$DEST/${TOP_DIR##*/}"
|
||||
cp -r -f -T "$TOP_DIR" "$STACK_DIR"
|
||||
chown -R $STACK_USER "$STACK_DIR"
|
||||
safe_chown -R $STACK_USER "$STACK_DIR"
|
||||
cd "$STACK_DIR"
|
||||
if [[ "$SHELL_AFTER_RUN" != "no" ]]; then
|
||||
exec sudo -u $STACK_USER bash -l -c "set -e; bash stack.sh; bash"
|
||||
@ -236,8 +236,8 @@ fi
|
||||
# Create the destination directory and ensure it is writable by the user
|
||||
# and read/executable by everybody for daemons (e.g. apache run for horizon)
|
||||
sudo mkdir -p $DEST
|
||||
sudo chown -R $STACK_USER $DEST
|
||||
chmod 0755 $DEST
|
||||
safe_chown -R $STACK_USER $DEST
|
||||
safe_chmod 0755 $DEST
|
||||
|
||||
# a basic test for $DEST path permissions (fatal on error unless skipped)
|
||||
check_path_perm_sanity ${DEST}
|
||||
@ -258,7 +258,7 @@ ENABLE_DEBUG_LOG_LEVEL=`trueorfalse True $ENABLE_DEBUG_LOG_LEVEL`
|
||||
# Destination path for service data
|
||||
DATA_DIR=${DATA_DIR:-${DEST}/data}
|
||||
sudo mkdir -p $DATA_DIR
|
||||
sudo chown -R $STACK_USER $DATA_DIR
|
||||
safe_chown -R $STACK_USER $DATA_DIR
|
||||
|
||||
|
||||
# Common Configuration
|
||||
@ -965,7 +965,7 @@ if is_service_enabled n-net q-dhcp; then
|
||||
clean_iptables
|
||||
rm -rf ${NOVA_STATE_PATH}/networks
|
||||
sudo mkdir -p ${NOVA_STATE_PATH}/networks
|
||||
sudo chown -R ${USER} ${NOVA_STATE_PATH}/networks
|
||||
safe_chown -R ${USER} ${NOVA_STATE_PATH}/networks
|
||||
# Force IP forwarding on, just in case
|
||||
sudo sysctl -w net.ipv4.ip_forward=1
|
||||
fi
|
||||
|
Loading…
Reference in New Issue
Block a user