Lints the executable scripts
This commit is contained in:
parent
7a85a95a54
commit
25069f4877
@ -3,27 +3,27 @@ _kickstart_readlink() {
|
|||||||
(
|
(
|
||||||
TARGET_FILE=$1
|
TARGET_FILE=$1
|
||||||
|
|
||||||
cd `dirname $TARGET_FILE`
|
cd "$(dirname "$TARGET_FILE")"
|
||||||
TARGET_FILE=`basename $TARGET_FILE`
|
TARGET_FILE=$(basename "$TARGET_FILE")
|
||||||
|
|
||||||
while [ -L "$TARGET_FILE" ]
|
while [ -L "$TARGET_FILE" ]
|
||||||
do
|
do
|
||||||
TARGET_FILE=`readlink $TARGET_FILE`
|
TARGET_FILE=$(readlink "$TARGET_FILE")
|
||||||
cd `dirname $TARGET_FILE`
|
cd "$(dirname "$TARGET_FILE")"
|
||||||
TARGET_FILE=`basename $TARGET_FILE`
|
TARGET_FILE=$(basename "$TARGET_FILE")
|
||||||
done
|
done
|
||||||
|
|
||||||
PHYS_DIR=`pwd -P`
|
PHYS_DIR=$(pwd -P)
|
||||||
RESULT=$PHYS_DIR/$TARGET_FILE
|
RESULT=$PHYS_DIR/$TARGET_FILE
|
||||||
echo $RESULT
|
echo "$RESULT"
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
path_to_kickstart=`which kickstart`
|
path_to_kickstart=$(which kickstart)
|
||||||
if [[ `uname` == "Darwin" ]]; then
|
if [[ "$(uname)" == "Darwin" ]]; then
|
||||||
curr_dir=$(dirname `_kickstart_readlink "$path_to_kickstart"`)
|
curr_dir=$(dirname "$(_kickstart_readlink "$path_to_kickstart")")
|
||||||
else
|
else
|
||||||
curr_dir=$(dirname `readlink -f "$path_to_kickstart"`)
|
curr_dir=$(dirname "$(readlink -f "$path_to_kickstart")")
|
||||||
fi
|
fi
|
||||||
|
|
||||||
command=${1:-help}
|
command=${1:-help}
|
||||||
@ -36,4 +36,4 @@ if ! [[ -x $command_file ]]; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
exec $command_file "$@"
|
exec "$command_file" "$@"
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
root_dir=`kickstart root-dir`
|
root_dir=$(kickstart root-dir)
|
||||||
echo "source $root_dir/completions/kickstart"
|
echo "source $root_dir/completions/kickstart"
|
||||||
|
@ -15,4 +15,4 @@ cat <<CMD
|
|||||||
CMD
|
CMD
|
||||||
)
|
)
|
||||||
|
|
||||||
tar chz -C `kickstart root-dir` . | ssh $target "$remote_command"
|
tar chz -C "$(kickstart root-dir)" . | ssh "$target" "$remote_command"
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
root_dir=`kickstart root-dir`
|
root_dir=$(kickstart root-dir)
|
||||||
echo "`ls $root_dir/lib | cut -f2- -d'-'`"
|
find "$root_dir"/lib -maxdepth | cut -f2- -d'-'
|
||||||
|
@ -4,13 +4,13 @@ module_loading=$(cat <<MODULE
|
|||||||
current_dir=\$(pwd)
|
current_dir=\$(pwd)
|
||||||
cd modules/kickstart
|
cd modules/kickstart
|
||||||
source install.sh
|
source install.sh
|
||||||
cd \$current_dir
|
cd "\$current_dir"
|
||||||
|
|
||||||
for module in modules/*; do
|
for module in modules/*; do
|
||||||
if [ ! \$module = module/kickstart ]; then
|
if [ ! "\$module" = module/kickstart ]; then
|
||||||
cd \$module
|
cd "\$module"
|
||||||
source install.sh
|
source install.sh
|
||||||
cd \$current_dir
|
cd "\$current_dir"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
MODULE
|
MODULE
|
||||||
@ -22,24 +22,24 @@ clean_up_compile_folder() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
link_folder() {
|
link_folder() {
|
||||||
[[ -h compile/$1 ]] || ln -s ../$1 compile/$1
|
[[ -h compile/"$1" ]] || ln -s ../"$1" compile/"$1"
|
||||||
}
|
}
|
||||||
|
|
||||||
link_modules() {
|
link_modules() {
|
||||||
mkdir -p compile/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
|
if [ -d modules ]; then
|
||||||
for module in modules/*; do
|
for module in modules/*; do
|
||||||
ln -s `pwd`/$module compile/$module
|
ln -s "$(pwd)"/"$module" compile/"$module"
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
compile_install() {
|
compile_install() {
|
||||||
cat <( echo -e "$module_loading" ) install.sh > compile/install.sh
|
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
|
echo "source roles/${role}.sh" >> compile/install.sh
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
@ -49,5 +49,5 @@ link_folder files
|
|||||||
link_folder recipes
|
link_folder recipes
|
||||||
link_folder roles
|
link_folder roles
|
||||||
link_modules
|
link_modules
|
||||||
compile_install $@
|
compile_install "$@"
|
||||||
echo -e "\necho Done" >> compile/install.sh
|
echo -e "\necho Done" >> compile/install.sh
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#!/bin/bash -e
|
#!/bin/bash -e
|
||||||
target=${1:-.}
|
target=${1:-.}
|
||||||
|
|
||||||
mkdir -p $target{,/roles,/recipes,/files}
|
mkdir -p "$target"{,/roles,/recipes,/files}
|
||||||
touch $target/{README.md,install.sh,roles/.gitkeep,recipes/.gitkeep,files/.gitkeep}
|
touch "$target"/{README.md,install.sh,roles/.gitkeep,recipes/.gitkeep,files/.gitkeep}
|
||||||
chmod +x $target/install.sh
|
chmod +x "$target"/install.sh
|
||||||
[ -f $target/.gitignore ] && echo "compile" > $target/.gitignore || echo "compile" >> $target/.gitignore
|
echo "compile" >> "$target"/.gitignore
|
||||||
|
@ -12,13 +12,13 @@ shift
|
|||||||
remote_command=$(
|
remote_command=$(
|
||||||
cat <<CMD
|
cat <<CMD
|
||||||
target=\$(mktemp -d -t kickstart.XXXXX)
|
target=\$(mktemp -d -t kickstart.XXXXX)
|
||||||
mkdir -p \$target
|
mkdir -p "\$target"
|
||||||
cd \$target
|
cd "\$target"
|
||||||
tar xz
|
tar xz
|
||||||
$prefix bash $debug install.sh
|
$prefix bash $debug install.sh
|
||||||
rm -rf \$target
|
rm -rf "\$target"
|
||||||
CMD
|
CMD
|
||||||
)
|
)
|
||||||
|
|
||||||
kickstart compile $@
|
kickstart compile "$@"
|
||||||
tar chz -C compile . | ssh $target "$remote_command"
|
tar chz -C compile . | ssh "$target" "$remote_command"
|
||||||
|
@ -1,12 +1,16 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
list() {
|
list() {
|
||||||
root_dir=`kickstart root-dir`
|
root_dir=$(kickstart root-dir)
|
||||||
find $root_dir/docs -type f | sed -e 's/.md$//' | cut -c `wc -c <<<$root_dir/docs/`- | tr '/' '.'
|
find "$root_dir"/docs -type f | sed -e 's/.md$//' | cut -c "$(wc -c <<<$root_dir/docs/)"- | tr '/' '.'
|
||||||
}
|
}
|
||||||
|
|
||||||
show() {
|
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
|
||||||
|
@ -4,24 +4,24 @@ image_name=${1:-$KICKSTART_DOCKER_IMAGE}
|
|||||||
image_name=${image_name:-moul/sshd}
|
image_name=${image_name:-moul/sshd}
|
||||||
|
|
||||||
pull_sshd_image() {
|
pull_sshd_image() {
|
||||||
docker pull $image_name
|
docker pull "$image_name"
|
||||||
}
|
}
|
||||||
|
|
||||||
remove_running_sshd() {
|
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"
|
[ "$runnig_sshd" ] && docker kill "$runnig_sshd" && docker rm "$runnig_sshd"
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
run_sshd() {
|
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
|
[ -z "$id" ] && echo "Docker container did't start" && return 1
|
||||||
|
|
||||||
echo "Connect using root:root on " `docker port $id 22`
|
echo "Connect using root:root on " "$(docker port "$id" 22)"
|
||||||
port=`docker port $id 22 | cut -f 2 -d :`
|
port=$(docker port "$id" 22 | cut -f 2 -d :)
|
||||||
echo For ssh: kickstart docker-ssh
|
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
|
pull_sshd_image
|
||||||
|
@ -3,8 +3,8 @@
|
|||||||
image_name=${1:-$KICKSTART_DOCKER_IMAGE}
|
image_name=${1:-$KICKSTART_DOCKER_IMAGE}
|
||||||
image_name=${image_name:-moul/sshd}
|
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
|
[ -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 :`
|
port=$(docker port "$runnig_sshd" 22 | cut -f 2 -d :)
|
||||||
exec ssh -p $port root@localhost
|
exec ssh -p "$port" root@localhost
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
cat <<EVAL
|
cat <<EVAL
|
||||||
current_dir=`pwd`
|
current_dir=$(pwd)
|
||||||
cd `kickstart root-dir`/kickstart/
|
cd $(kickstart root-dir)/kickstart/
|
||||||
source install.sh
|
source install.sh
|
||||||
cd \$current_dir
|
cd "\$current_dir"
|
||||||
EVAL
|
EVAL
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
[[ "$1" == "--sudo" ]] && prefix="sudo " && shift
|
[[ "$1" == "--sudo" ]] && prefix="sudo " && shift
|
||||||
[ "$DEBUG" ] && debug="-x"
|
[ "$DEBUG" ] && debug="-x"
|
||||||
|
|
||||||
kickstart compile $@
|
kickstart compile "$@"
|
||||||
(
|
(
|
||||||
cd compile
|
cd compile
|
||||||
$prefix bash $debug install.sh
|
$prefix bash $debug install.sh
|
||||||
|
@ -4,26 +4,27 @@ _kickstart_readlink() {
|
|||||||
(
|
(
|
||||||
TARGET_FILE=$1
|
TARGET_FILE=$1
|
||||||
|
|
||||||
cd `dirname $TARGET_FILE`
|
cd "$(dirname "$TARGET_FILE")"
|
||||||
TARGET_FILE=`basename $TARGET_FILE`
|
TARGET_FILE=$(basename "$TARGET_FILE")
|
||||||
|
|
||||||
while [ -L "$TARGET_FILE" ]
|
while [ -L "$TARGET_FILE" ]
|
||||||
do
|
do
|
||||||
TARGET_FILE=`readlink $TARGET_FILE`
|
TARGET_FILE=$(readlink "$TARGET_FILE")
|
||||||
cd `dirname $TARGET_FILE`
|
cd "$(dirname "$TARGET_FILE")"
|
||||||
TARGET_FILE=`basename $TARGET_FILE`
|
TARGET_FILE=$(basename "$TARGET_FILE")
|
||||||
done
|
done
|
||||||
|
|
||||||
PHYS_DIR=`pwd -P`
|
PHYS_DIR=$(pwd -P)
|
||||||
RESULT=$PHYS_DIR/$TARGET_FILE
|
RESULT=$PHYS_DIR/$TARGET_FILE
|
||||||
echo $RESULT
|
echo "$RESULT"
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
path_to_kickstart=`which kickstart`
|
path_to_kickstart=$(which kickstart)
|
||||||
if [[ `uname` == "Darwin" ]]; then
|
if [[ $(uname) == "Darwin" ]]; then
|
||||||
dirname $(dirname `_kickstart_readlink "$path_to_kickstart"`)
|
resolved_path_to_kickstart_bin=$(_kickstart_readlink "$path_to_kickstart")
|
||||||
else
|
else
|
||||||
dirname $(dirname `readlink -f "$path_to_kickstart"`)
|
resolved_path_to_kickstart_bin=$(readlink -f "$path_to_kickstart")
|
||||||
fi
|
fi
|
||||||
|
dirname "$(dirname "$resolved_path_to_kickstart_bin")"
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user