Lints the executable scripts

This commit is contained in:
Bruno Tavares 2015-05-20 17:16:16 -03:00
parent 7a85a95a54
commit 25069f4877
13 changed files with 67 additions and 62 deletions

View File

@ -3,27 +3,27 @@ _kickstart_readlink() {
(
TARGET_FILE=$1
cd `dirname $TARGET_FILE`
TARGET_FILE=`basename $TARGET_FILE`
cd "$(dirname "$TARGET_FILE")"
TARGET_FILE=$(basename "$TARGET_FILE")
while [ -L "$TARGET_FILE" ]
do
TARGET_FILE=`readlink $TARGET_FILE`
cd `dirname $TARGET_FILE`
TARGET_FILE=`basename $TARGET_FILE`
TARGET_FILE=$(readlink "$TARGET_FILE")
cd "$(dirname "$TARGET_FILE")"
TARGET_FILE=$(basename "$TARGET_FILE")
done
PHYS_DIR=`pwd -P`
PHYS_DIR=$(pwd -P)
RESULT=$PHYS_DIR/$TARGET_FILE
echo $RESULT
echo "$RESULT"
)
}
path_to_kickstart=`which kickstart`
if [[ `uname` == "Darwin" ]]; then
curr_dir=$(dirname `_kickstart_readlink "$path_to_kickstart"`)
path_to_kickstart=$(which kickstart)
if [[ "$(uname)" == "Darwin" ]]; then
curr_dir=$(dirname "$(_kickstart_readlink "$path_to_kickstart")")
else
curr_dir=$(dirname `readlink -f "$path_to_kickstart"`)
curr_dir=$(dirname "$(readlink -f "$path_to_kickstart")")
fi
command=${1:-help}
@ -36,4 +36,4 @@ if ! [[ -x $command_file ]]; then
exit 1
fi
exec $command_file "$@"
exec "$command_file" "$@"

View File

@ -1,4 +1,4 @@
#!/bin/bash
root_dir=`kickstart root-dir`
root_dir=$(kickstart root-dir)
echo "source $root_dir/completions/kickstart"

View File

@ -15,4 +15,4 @@ cat <<CMD
CMD
)
tar chz -C `kickstart root-dir` . | ssh $target "$remote_command"
tar chz -C "$(kickstart root-dir)" . | ssh "$target" "$remote_command"

View File

@ -1,4 +1,4 @@
#!/bin/bash
root_dir=`kickstart root-dir`
echo "`ls $root_dir/lib | cut -f2- -d'-'`"
root_dir=$(kickstart root-dir)
find "$root_dir"/lib -maxdepth | cut -f2- -d'-'

View File

@ -4,13 +4,13 @@ module_loading=$(cat <<MODULE
current_dir=\$(pwd)
cd modules/kickstart
source install.sh
cd \$current_dir
cd "\$current_dir"
for module in modules/*; do
if [ ! \$module = module/kickstart ]; then
cd \$module
if [ ! "\$module" = module/kickstart ]; then
cd "\$module"
source install.sh
cd \$current_dir
cd "\$current_dir"
fi
done
MODULE
@ -22,24 +22,24 @@ clean_up_compile_folder() {
}
link_folder() {
[[ -h compile/$1 ]] || ln -s ../$1 compile/$1
[[ -h compile/"$1" ]] || ln -s ../"$1" compile/"$1"
}
link_modules() {
mkdir -p compile/modules
ln -s `kickstart root-dir`/kickstart compile/modules/kickstart
ln -s "$(kickstart root-dir)"/kickstart compile/modules/kickstart
if [ -d modules ]; then
for module in modules/*; do
ln -s `pwd`/$module compile/$module
ln -s "$(pwd)"/"$module" compile/"$module"
done
fi
}
compile_install() {
cat <( echo -e "$module_loading" ) install.sh > compile/install.sh
for role in $@; do
for role in "$@"; do
echo "source roles/${role}.sh" >> compile/install.sh
done
}
@ -49,5 +49,5 @@ link_folder files
link_folder recipes
link_folder roles
link_modules
compile_install $@
compile_install "$@"
echo -e "\necho Done" >> compile/install.sh

View File

@ -1,7 +1,7 @@
#!/bin/bash -e
target=${1:-.}
mkdir -p $target{,/roles,/recipes,/files}
touch $target/{README.md,install.sh,roles/.gitkeep,recipes/.gitkeep,files/.gitkeep}
chmod +x $target/install.sh
[ -f $target/.gitignore ] && echo "compile" > $target/.gitignore || echo "compile" >> $target/.gitignore
mkdir -p "$target"{,/roles,/recipes,/files}
touch "$target"/{README.md,install.sh,roles/.gitkeep,recipes/.gitkeep,files/.gitkeep}
chmod +x "$target"/install.sh
echo "compile" >> "$target"/.gitignore

View File

@ -12,13 +12,13 @@ shift
remote_command=$(
cat <<CMD
target=\$(mktemp -d -t kickstart.XXXXX)
mkdir -p \$target
cd \$target
mkdir -p "\$target"
cd "\$target"
tar xz
$prefix bash $debug install.sh
rm -rf \$target
rm -rf "\$target"
CMD
)
kickstart compile $@
tar chz -C compile . | ssh $target "$remote_command"
kickstart compile "$@"
tar chz -C compile . | ssh "$target" "$remote_command"

View File

@ -1,12 +1,16 @@
#!/bin/bash
list() {
root_dir=`kickstart root-dir`
find $root_dir/docs -type f | sed -e 's/.md$//' | cut -c `wc -c <<<$root_dir/docs/`- | tr '/' '.'
root_dir=$(kickstart root-dir)
find "$root_dir"/docs -type f | sed -e 's/.md$//' | cut -c "$(wc -c <<<$root_dir/docs/)"- | tr '/' '.'
}
show() {
cat `kickstart root-dir`/docs/$(echo $1 | tr '.' '/').md
cat "$(kickstart root-dir)"/docs/"$(echo "$1" | tr '.' '/')".md
}
[ -z "$1" ] && list || show $1
if [ -z "$1" ]; then
list
else
show "$1"
fi

View File

@ -4,24 +4,24 @@ image_name=${1:-$KICKSTART_DOCKER_IMAGE}
image_name=${image_name:-moul/sshd}
pull_sshd_image() {
docker pull $image_name
docker pull "$image_name"
}
remove_running_sshd() {
runnig_sshd=$(docker ps -q $image_name)
runnig_sshd=$(docker ps -q "$image_name")
[ "$runnig_sshd" ] && docker kill "$runnig_sshd" && docker rm "$runnig_sshd"
true
}
run_sshd() {
id=$(docker run -p 22 -d $image_name)
id=$(docker run -p 22 -d "$image_name")
[ -z "$id" ] && echo "Docker container did't start" && return 1
echo "Connect using root:root on " `docker port $id 22`
port=`docker port $id 22 | cut -f 2 -d :`
echo "Connect using root:root on " "$(docker port "$id" 22)"
port=$(docker port "$id" 22 | cut -f 2 -d :)
echo For ssh: kickstart docker-ssh
echo For deploy: kickstart deploy \"-p $port root@localhost\" '[roles]'
echo For deploy: kickstart deploy \"-p "$port" root@localhost\" '[roles]'
}
pull_sshd_image

View File

@ -3,8 +3,8 @@
image_name=${1:-$KICKSTART_DOCKER_IMAGE}
image_name=${image_name:-moul/sshd}
runnig_sshd=$(docker ps -q $image_name)
runnig_sshd=$(docker ps -q "$image_name")
[ -z "$runnig_sshd" ] && echo "Docker container not created. Run \`kickstart docker-create\` to get one" && exit 1
port=`docker port $runnig_sshd 22 | cut -f 2 -d :`
exec ssh -p $port root@localhost
port=$(docker port "$runnig_sshd" 22 | cut -f 2 -d :)
exec ssh -p "$port" root@localhost

View File

@ -1,8 +1,8 @@
#!/bin/bash
cat <<EVAL
current_dir=`pwd`
cd `kickstart root-dir`/kickstart/
current_dir=$(pwd)
cd $(kickstart root-dir)/kickstart/
source install.sh
cd \$current_dir
cd "\$current_dir"
EVAL

View File

@ -3,7 +3,7 @@
[[ "$1" == "--sudo" ]] && prefix="sudo " && shift
[ "$DEBUG" ] && debug="-x"
kickstart compile $@
kickstart compile "$@"
(
cd compile
$prefix bash $debug install.sh

View File

@ -4,26 +4,27 @@ _kickstart_readlink() {
(
TARGET_FILE=$1
cd `dirname $TARGET_FILE`
TARGET_FILE=`basename $TARGET_FILE`
cd "$(dirname "$TARGET_FILE")"
TARGET_FILE=$(basename "$TARGET_FILE")
while [ -L "$TARGET_FILE" ]
do
TARGET_FILE=`readlink $TARGET_FILE`
cd `dirname $TARGET_FILE`
TARGET_FILE=`basename $TARGET_FILE`
TARGET_FILE=$(readlink "$TARGET_FILE")
cd "$(dirname "$TARGET_FILE")"
TARGET_FILE=$(basename "$TARGET_FILE")
done
PHYS_DIR=`pwd -P`
PHYS_DIR=$(pwd -P)
RESULT=$PHYS_DIR/$TARGET_FILE
echo $RESULT
echo "$RESULT"
)
}
path_to_kickstart=`which kickstart`
if [[ `uname` == "Darwin" ]]; then
dirname $(dirname `_kickstart_readlink "$path_to_kickstart"`)
path_to_kickstart=$(which kickstart)
if [[ $(uname) == "Darwin" ]]; then
resolved_path_to_kickstart_bin=$(_kickstart_readlink "$path_to_kickstart")
else
dirname $(dirname `readlink -f "$path_to_kickstart"`)
resolved_path_to_kickstart_bin=$(readlink -f "$path_to_kickstart")
fi
dirname "$(dirname "$resolved_path_to_kickstart_bin")"