Lints the code using shellcheck
This commit is contained in:
parent
e1bf0b113c
commit
7a85a95a54
@ -1,11 +1,11 @@
|
||||
kickstart.info() {
|
||||
[ "$kickstart_context" ] && echo "$kickstart_context >> $@" >&2 || echo "$@" >&2
|
||||
[ "$kickstart_context" ] && echo "$kickstart_context >> $*" >&2 || echo "$*" >&2
|
||||
}
|
||||
|
||||
kickstart.context() {
|
||||
kickstart_context=""
|
||||
kickstart.info "Setting up $@"
|
||||
kickstart_context="$@"
|
||||
kickstart.info "Setting up $*"
|
||||
kickstart_context="$*"
|
||||
}
|
||||
|
||||
kickstart.debugging?() {
|
||||
@ -13,17 +13,17 @@ kickstart.debugging?() {
|
||||
}
|
||||
|
||||
kickstart.mute() {
|
||||
kickstart.info "Running \"$@\""
|
||||
kickstart.info "Running \"$*\""
|
||||
if kickstart.debugging?; then
|
||||
"$@"
|
||||
"$*"
|
||||
else
|
||||
`"$@" >/dev/null 2>&1`
|
||||
"$*" >/dev/null 2>&1
|
||||
fi
|
||||
return $?
|
||||
}
|
||||
|
||||
kickstart.command_exists() {
|
||||
which $1 >/dev/null 2>&1
|
||||
which "$1" >/dev/null 2>&1
|
||||
}
|
||||
|
||||
kickstart.print_with_separator() {
|
||||
@ -35,5 +35,5 @@ kickstart.print_with_separator() {
|
||||
}
|
||||
|
||||
for recipe in recipes/kickstart/*.sh; do
|
||||
source $recipe
|
||||
source "$recipe"
|
||||
done
|
||||
|
@ -1,12 +1,12 @@
|
||||
kickstart.apt.ppa() {
|
||||
kickstart.mute add-apt-repository -y $1
|
||||
kickstart.mute add-apt-repository -y "$1"
|
||||
kickstart.package.update
|
||||
}
|
||||
|
||||
kickstart.apt.add_key_from_url() {
|
||||
kickstart.download.stream $1 | kickstart.mute apt-key add -
|
||||
kickstart.download.stream "$1" | kickstart.mute apt-key add -
|
||||
}
|
||||
|
||||
kickstart.apt.add_key_from_keychain() {
|
||||
kickstart.mute apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv $1
|
||||
kickstart.mute apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv "$1"
|
||||
}
|
||||
|
@ -1,13 +1,13 @@
|
||||
kickstart.download.file() {
|
||||
kickstart.download.stream $1 > $2
|
||||
kickstart.download.stream "$1" > "$2"
|
||||
}
|
||||
|
||||
kickstart.download.stream() {
|
||||
kickstart.info "Downloading $1"
|
||||
if [ `which curl` ]; then
|
||||
curl -Ls $1
|
||||
elif [ `which wget` ]; then
|
||||
wget -qO - $1
|
||||
if which curl; then
|
||||
curl -Ls "$1"
|
||||
elif which wget; then
|
||||
wget -qO - "$1"
|
||||
else
|
||||
kickstart.info "No download application found, consider installing curl or wget"
|
||||
exit 1
|
||||
|
@ -1,14 +1,14 @@
|
||||
kickstart.file.link() {
|
||||
rm -rf $2 2>/dev/null
|
||||
ln -s $1 $2
|
||||
rm -rf "$2" 2>/dev/null
|
||||
ln -s "$1" "$2"
|
||||
}
|
||||
|
||||
kickstart.file.contains() {
|
||||
grep -q "$2" $1 2>/dev/null
|
||||
grep -q "$2" "$1" 2>/dev/null
|
||||
}
|
||||
|
||||
kickstart.file.template() {
|
||||
file=$1
|
||||
file="$1"
|
||||
shift
|
||||
kickstart.stream.template "$@" < $file
|
||||
kickstart.stream.template "$@" < "$file"
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
kickstart.group.create() {
|
||||
kickstart.info "Creating group $1"
|
||||
kickstart.file.contains /etc/group $1 || groupadd $1
|
||||
kickstart.file.contains /etc/group "$1" || groupadd "$1"
|
||||
}
|
||||
|
@ -1,14 +1,15 @@
|
||||
kickstart.module.apply_role() {
|
||||
kickstart.module.apply_ $1 $2 roles
|
||||
kickstart.module.apply_ "$1" "$2" roles
|
||||
}
|
||||
|
||||
kickstart.module.apply_recipe() {
|
||||
kickstart.module.apply_ $1 $2 recipes
|
||||
kickstart.module.apply_ "$1" "$2" recipes
|
||||
}
|
||||
|
||||
kickstart.module.apply_() {
|
||||
local cur_dir=`pwd`
|
||||
cd modules/$1
|
||||
source $3/$2.sh
|
||||
cd $cur_dir
|
||||
local cur_dir;
|
||||
cur_dir=$(pwd)
|
||||
cd modules/"$1"
|
||||
source "$3"/"$2".sh
|
||||
cd "$cur_dir"
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ kickstart.os() {
|
||||
}
|
||||
|
||||
kickstart.os.is() {
|
||||
[[ `kickstart.os` == "$1" ]]
|
||||
[[ $(kickstart.os) == "$1" ]]
|
||||
}
|
||||
|
||||
kickstart.os.codename() {
|
||||
|
@ -7,5 +7,5 @@ kickstart.package.manager() {
|
||||
}
|
||||
|
||||
for recipe in recipes/kickstart/package/*.sh; do
|
||||
source $recipe
|
||||
source "$recipe"
|
||||
done
|
||||
|
@ -1,24 +1,24 @@
|
||||
kickstart.package.install() {
|
||||
if kickstart.package.installed "$@"; then
|
||||
kickstart.info "$@ already installed"
|
||||
if kickstart.package.installed "$*"; then
|
||||
kickstart.info "$* already installed"
|
||||
else
|
||||
kickstart.info "No packages found matching $@. Installing..."
|
||||
kickstart.package.install.`kickstart.package.manager` "$@"
|
||||
kickstart.info "No packages found matching $*. Installing..."
|
||||
kickstart.package.install."$(kickstart.package.manager)" "$*"
|
||||
fi
|
||||
}
|
||||
|
||||
kickstart.package.install.apt-get() {
|
||||
kickstart.mute apt-get install -y "$@"
|
||||
kickstart.mute apt-get install -y "$*"
|
||||
}
|
||||
|
||||
kickstart.package.install.brew() {
|
||||
kickstart.mute brew install -y "$@"
|
||||
kickstart.mute brew install -y "$*"
|
||||
}
|
||||
|
||||
kickstart.package.install.yum() {
|
||||
kickstart.mute yum install -y "$@"
|
||||
kickstart.mute yum install -y "$*"
|
||||
}
|
||||
|
||||
kickstart.package.install.pacman() {
|
||||
kickstart.mute pacman -S --noconfirm "$@"
|
||||
kickstart.mute pacman -S --noconfirm "$*"
|
||||
}
|
||||
|
@ -1,23 +1,24 @@
|
||||
kickstart.package.installed() {
|
||||
kickstart.package.installed.`kickstart.package.manager` "$@"
|
||||
kickstart.package.installed."$(kickstart.package.manager)" "$*"
|
||||
}
|
||||
|
||||
kickstart.package.installed.apt-get() {
|
||||
kickstart.mute dpkg -s "$@"
|
||||
kickstart.mute dpkg -s "$*"
|
||||
}
|
||||
|
||||
kickstart.package.installed.brew() {
|
||||
! $(brew info "$@" | kickstart.stream.contains "Not installed")
|
||||
! brew info "$*" | kickstart.stream.contains "Not installed"
|
||||
}
|
||||
|
||||
kickstart.package.installed.pacman() {
|
||||
kickstart.mute pacman -Q "$@"
|
||||
kickstart.mute pacman -Q "$*"
|
||||
}
|
||||
|
||||
kickstart.package.installed.yum() {
|
||||
local yum_packages="`yum list installed`"
|
||||
local yum_packages;
|
||||
yum_packages=$(yum list installed)
|
||||
for package in "$@"; do
|
||||
kickstart.stream.contains $package <<<$yum_packages || return 1
|
||||
kickstart.stream.contains "$package" <<<$yum_packages || return 1
|
||||
done
|
||||
return 0
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
kickstart.package.update() {
|
||||
kickstart.package.update.`kickstart.package.manager`
|
||||
kickstart.package.update."$(kickstart.package.manager)"
|
||||
}
|
||||
|
||||
kickstart.package.update.apt-get() {
|
||||
|
@ -1,5 +1,5 @@
|
||||
kickstart.package.upgrade() {
|
||||
kickstart.package.upgrade.`kickstart.package.manager`
|
||||
kickstart.package.upgrade."$(kickstart.package.manager)"
|
||||
}
|
||||
|
||||
kickstart.package.upgrade.apt-get() {
|
||||
|
@ -1,21 +1,22 @@
|
||||
kickstart.profile.add_to_profile() {
|
||||
local file=$1
|
||||
[ ! -f files/$file ] && kickstart.info "File files/$file not found" && exit 1
|
||||
[ ! -f files/"$file" ] && kickstart.info "File files/$file not found" && exit 1
|
||||
|
||||
local profile_d=`kickstart.profile.location.profile_d`
|
||||
mkdir -p $profile_d
|
||||
local profile_d;
|
||||
profile_d=$(kickstart.profile.location.profile_d)
|
||||
mkdir -p "$profile_d"
|
||||
|
||||
cp files/$file $profile_d/$file
|
||||
cp files/"$file" "$profile_d"/"$file"
|
||||
|
||||
kickstart.profile.source_on_configuration_file $file $profile_d `kickstart.profile.location.zsh`
|
||||
kickstart.os.is Mac && kickstart.profile.source_on_configuration_file $file $profile_d `kickstart.profile.location.bash`
|
||||
kickstart.profile.source_on_configuration_file "$file" "$profile_d" "$(kickstart.profile.location.zsh)"
|
||||
kickstart.os.is Mac && kickstart.profile.source_on_configuration_file "$file" "$profile_d" "$(kickstart.profile.location.bash)"
|
||||
}
|
||||
|
||||
kickstart.profile.source_on_configuration_file() {
|
||||
local file=$1
|
||||
local profile_d=$2
|
||||
local configuration=$3
|
||||
kickstart.file.contains $configuration $file || ( echo "[[ -f $profile_d/$file ]] && source $profile_d/$file" >> $configuration )
|
||||
kickstart.file.contains "$configuration" "$file" || ( echo "[[ -f $profile_d/$file ]] && source $profile_d/$file" >> "$configuration" )
|
||||
}
|
||||
|
||||
kickstart.profile.location.profile_d() {
|
||||
|
@ -1,27 +1,27 @@
|
||||
kickstart.service.enable() {
|
||||
kickstart.command_exists enable && enable $1
|
||||
kickstart.command_exists systemctl && systemctl enable $1
|
||||
kickstart.command_exists enable && enable "$1"
|
||||
kickstart.command_exists systemctl && systemctl enable "$1"
|
||||
kickstart.os.is "Mac" && kickstart.info "Mac services not supported yet"
|
||||
}
|
||||
kickstart.service.disable() {
|
||||
kickstart.command_exists disable && disable $1
|
||||
kickstart.command_exists systemctl && systemctl disable $1
|
||||
kickstart.command_exists disable && disable "$1"
|
||||
kickstart.command_exists systemctl && systemctl disable "$1"
|
||||
kickstart.os.is "Mac" && kickstart.info "Mac services not supported yet"
|
||||
}
|
||||
|
||||
kickstart.service.start() {
|
||||
kickstart.command_exists start && start $1
|
||||
kickstart.command_exists systemctl && systemctl start $1
|
||||
kickstart.command_exists start && start "$1"
|
||||
kickstart.command_exists systemctl && systemctl start "$1"
|
||||
kickstart.os.is "Mac" && kickstart.info "Mac services not supported yet"
|
||||
}
|
||||
|
||||
kickstart.service.stop() {
|
||||
kickstart.command_exists stop && stop $1
|
||||
kickstart.command_exists systemctl && systemctl stop $1
|
||||
kickstart.command_exists stop && stop "$1"
|
||||
kickstart.command_exists systemctl && systemctl stop "$1"
|
||||
kickstart.os.is "Mac" && kickstart.info "Mac services not supported yet"
|
||||
}
|
||||
|
||||
kickstart.service.restart() {
|
||||
kickstart.service.stop $1
|
||||
kickstart.service.start $1
|
||||
kickstart.service.stop "$1"
|
||||
kickstart.service.start "$1"
|
||||
}
|
||||
|
@ -1,33 +1,34 @@
|
||||
kickstart.user.exists?() {
|
||||
kickstart.mute id $1
|
||||
kickstart.mute id "$1"
|
||||
}
|
||||
|
||||
kickstart.user.create() {
|
||||
kickstart.user.exists? $1 || ( useradd -m -s /bin/bash -U -p `openssl passwd -1 $2` $1 )
|
||||
kickstart.user.exists? "$1" || ( useradd -m -s /bin/bash -U -p "$(openssl passwd -1 "$2")" "$1" )
|
||||
}
|
||||
|
||||
kickstart.user.is_on_group() {
|
||||
id -nG $1 | kickstart.stream.contains $2
|
||||
id -nG "$1" | kickstart.stream.contains "$2"
|
||||
}
|
||||
|
||||
kickstart.user.add_group() {
|
||||
kickstart.info "Adding $2 group to $1"
|
||||
kickstart.user.is_on_group $1 $2 || usermod -a -G $2 $1
|
||||
kickstart.user.is_on_group "$1" "$2" || usermod -a -G "$2" "$1"
|
||||
}
|
||||
|
||||
kickstart.user.remove_group() {
|
||||
kickstart.info "Remove $1 from group $2"
|
||||
kickstart.user.is_on_group $1 $2 && \
|
||||
IFS=" " read -a groups < <(id -nG $1 | sed "s/$2//") && \
|
||||
usermod -G `kickstart.print_with_separator , ${groups[*]}` $1
|
||||
kickstart.user.is_on_group "$1" "$2" && \
|
||||
IFS=" " read -a groups < <(id -nG "$1" | sed "s/$2//") && \
|
||||
usermod -G "$(kickstart.print_with_separator , "${groups[*]}")" "$1"
|
||||
}
|
||||
|
||||
kickstart.user.homeFolder() {
|
||||
grep ^$1 /etc/passwd | cut -d: -f 6
|
||||
grep ^"$1" /etc/passwd | cut -d: -f 6
|
||||
}
|
||||
|
||||
kickstart.user.exec.command.module() {
|
||||
local cur_dir=`pwd`
|
||||
local cur_dir;
|
||||
cur_dir=$(pwd)
|
||||
cat <<COMMAND
|
||||
cd modules/kickstart
|
||||
source install.sh
|
||||
@ -49,13 +50,13 @@ kickstart.user.exec() {
|
||||
|
||||
local command=''
|
||||
kickstart.command_exists kickstart && \
|
||||
command=`kickstart.user.exec.command.infect "$@"` || \
|
||||
command=`kickstart.user.exec.command.module "$@"`
|
||||
command=$(kickstart.user.exec.command.infect "$*") || \
|
||||
command=$(kickstart.user.exec.command.module "$*")
|
||||
|
||||
kickstart.info Running \'"$@"\' as $user
|
||||
sudo -H -u $user bash -c "$command"
|
||||
kickstart.info Running \'"$*"\' as "$user"
|
||||
sudo -H -u "$user" bash -c "$command"
|
||||
}
|
||||
|
||||
kickstart.user.root?() {
|
||||
[ `whoami` == root ]
|
||||
[ "$(whoami)" == root ]
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user