mirror of
https://github.com/ViViDboarder/shoestrap.git
synced 2024-11-24 02:26:31 +00:00
Update packages to install multiple packages and a bunch of linting updates
This commit is contained in:
parent
72d5ffaa4f
commit
f9fa0ba17d
126
helpers/default
126
helpers/default
@ -4,7 +4,7 @@
|
||||
# DO NOT MODIFY THIS FILE. Instead, modify 'helpers/custom'.
|
||||
##############################################################################
|
||||
|
||||
COOKBOOK_NAME="$(basename $0)"
|
||||
COOKBOOK_NAME="$(basename "$0")"
|
||||
if [ -z "$SHOESTRAP_BASE" ]; then
|
||||
DIR="$( cd "$( dirname "$0" )" && pwd )"
|
||||
else
|
||||
@ -24,19 +24,19 @@ recipe () {
|
||||
local default_recipe="$DIR/recipes/default/$CURRENT_RECIPE_NAME"
|
||||
local cookbook_recipe="$DIR/recipes/$COOKBOOK_NAME/$CURRENT_RECIPE_NAME"
|
||||
|
||||
if [ -f $cookbook_recipe ]; then
|
||||
if [ -f "$cookbook_recipe" ]; then
|
||||
log "Running recipe '$cookbook_recipe'..." 1
|
||||
separator
|
||||
. $cookbook_recipe
|
||||
elif [ -f $default_recipe ]; then
|
||||
. "$cookbook_recipe"
|
||||
elif [ -f "$default_recipe" ]; then
|
||||
log "Running recipe '$default_recipe'..." 1
|
||||
separator
|
||||
. $default_recipe
|
||||
. "$default_recipe"
|
||||
else
|
||||
error "Could not find recipe for '$CURRENT_RECIPE_NAME'. Fail!"
|
||||
fi
|
||||
|
||||
cd $DIR
|
||||
cd "$DIR" || error "Failed to find recipe"
|
||||
}
|
||||
|
||||
#
|
||||
@ -61,13 +61,13 @@ finished () {
|
||||
#
|
||||
log () {
|
||||
if [[ $2 -gt 0 ]]; then
|
||||
spacer $2
|
||||
spacer "$2"
|
||||
fi
|
||||
|
||||
echo " * $1"
|
||||
|
||||
if [[ $3 -gt 0 ]]; then
|
||||
spacer $3
|
||||
spacer "$3"
|
||||
fi
|
||||
}
|
||||
|
||||
@ -91,7 +91,7 @@ spacer () {
|
||||
local spaces=1
|
||||
fi
|
||||
|
||||
for (( i=0; i<$spaces; i++ )) do
|
||||
for (( i=0; i<spaces; i++ )) do
|
||||
echo ""
|
||||
done
|
||||
}
|
||||
@ -115,41 +115,18 @@ separator () {
|
||||
local char='-'
|
||||
fi
|
||||
|
||||
local width=$(tput cols)
|
||||
local width=""
|
||||
width=$(tput cols)
|
||||
|
||||
for (( i=0; i < $width-2; i++ )) do
|
||||
for (( i=0; i < width-2; i++ )) do
|
||||
local output="$output$char"
|
||||
done
|
||||
echo $output
|
||||
echo "$output"
|
||||
}
|
||||
|
||||
#
|
||||
# Update packages in package manager.
|
||||
#
|
||||
package_update () {
|
||||
log "Updating package manager..." 0 1
|
||||
detect_package_manager
|
||||
|
||||
if [ "$PACKAGE_MANAGER" == 'apt-get' ]; then
|
||||
apt-get update -y
|
||||
elif [ "$PACKAGE_MANAGER" == 'yum' ]; then
|
||||
yum check-update -y
|
||||
elif [ "$PACKAGE_MANAGER" == 'port' ]; then
|
||||
port selfupdate
|
||||
elif [ "$PACKAGE_MANAGER" == 'brew' ]; then
|
||||
brew update
|
||||
else
|
||||
error "Unknown package manager: $PACKAGE_MANAGER"
|
||||
fi
|
||||
|
||||
if [ $? -ne 0 ]; then
|
||||
error "An error occured while updating packages. Fail!"
|
||||
else
|
||||
spacer 2
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
sudo_package_update () {
|
||||
log "Updating package manager..." 0 1
|
||||
detect_package_manager
|
||||
@ -174,66 +151,27 @@ sudo_package_update () {
|
||||
}
|
||||
|
||||
#
|
||||
# Install a package through package manager
|
||||
# Install a package or packages through package manager
|
||||
#
|
||||
package () {
|
||||
log "Installing package '$1'..."
|
||||
detect_package_manager
|
||||
|
||||
test_package_installed $1 > /dev/null 2>&1
|
||||
|
||||
if [ $? -eq 0 ]; then
|
||||
log "Package '$1' is already installed. Skipping."
|
||||
return 0
|
||||
fi
|
||||
|
||||
if [ "$PACKAGE_MANAGER" == 'apt-get' ]; then
|
||||
DEBIAN_FRONTEND=noninteractive apt-get install -y --force-yes $1
|
||||
elif [ "$PACKAGE_MANAGER" == 'yum' ]; then
|
||||
yum install -y $1
|
||||
elif [ "$PACKAGE_MANAGER" == 'port' ]; then
|
||||
# Unintuitive, but this skips all promps which should assume Y
|
||||
port -N install $1
|
||||
elif [ "$PACKAGE_MANAGER" == 'brew' ]; then
|
||||
brew install $1
|
||||
else
|
||||
error "Unknown package manager: $PACKAGE_MANAGER"
|
||||
fi
|
||||
|
||||
if [ $? -ne 0 ]; then
|
||||
error "An error occured while installing package '$1'. Fail!"
|
||||
else
|
||||
spacer 2
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
sudo_package () {
|
||||
log "Installing package '$1'..."
|
||||
log "Installing packages '$*'..."
|
||||
detect_package_manager
|
||||
|
||||
test_package_installed $1 > /dev/null 2>&1
|
||||
|
||||
if [ $? -eq 0 ]; then
|
||||
log "Package '$1' is already installed. Skipping."
|
||||
return 0
|
||||
fi
|
||||
|
||||
if [ "$PACKAGE_MANAGER" == 'apt-get' ]; then
|
||||
DEBIAN_FRONTEND=noninteractive sudo apt-get install -y --force-yes $1
|
||||
DEBIAN_FRONTEND=noninteractive sudo apt-get install -y --allow $*
|
||||
elif [ "$PACKAGE_MANAGER" == 'yum' ]; then
|
||||
sudo yum install -y $1
|
||||
sudo yum install -y $*
|
||||
elif [ "$PACKAGE_MANAGER" == 'port' ]; then
|
||||
# Unintuitive, but this skips all promps which should assume Y
|
||||
sudo port -N install $1
|
||||
sudo port -N install $*
|
||||
elif [ "$PACKAGE_MANAGER" == 'brew' ]; then
|
||||
brew install $1
|
||||
brew install $*
|
||||
else
|
||||
error "Unknown package manager: $PACKAGE_MANAGER"
|
||||
fi
|
||||
|
||||
if [ $? -ne 0 ]; then
|
||||
error "An error occured while installing package '$1'. Fail!"
|
||||
error "An error occured while installing packages. Fail!"
|
||||
else
|
||||
spacer 2
|
||||
fi
|
||||
@ -354,17 +292,17 @@ try_link () {
|
||||
src="$src"
|
||||
elif [ -f "$cookbook_assets_source" ]; then
|
||||
src="$cookbook_assets_source"
|
||||
elif [ -f $default_assets_source ]; then
|
||||
elif [ -f "$default_assets_source" ]; then
|
||||
src="$default_assets_source"
|
||||
elif [ -d "$cookbook_assets_source" ]; then
|
||||
src="$cookbook_assets_source"
|
||||
elif [ -d $default_assets_source ]; then
|
||||
elif [ -d "$default_assets_source" ]; then
|
||||
src="$default_assets_source"
|
||||
else
|
||||
error "Could not find '$1' to link Fail!"
|
||||
fi
|
||||
|
||||
if [ -L "$2" ] && [ "$(readlink $2)" == "$src" ] ; then
|
||||
if [ -L "$2" ] && [ "$(readlink "$2")" == "$src" ] ; then
|
||||
log "Link already exists: $2"
|
||||
else
|
||||
log "Creating link: $2 -> $src"
|
||||
@ -380,18 +318,16 @@ add_user () {
|
||||
local pass=$2
|
||||
local args=$3
|
||||
|
||||
id $user > /dev/null 2>&1
|
||||
|
||||
if [ $? -eq 0 ]; then
|
||||
if id "$user" > /dev/null 2>&1 ; then
|
||||
log "User $user already exists. Skipped creation."
|
||||
else
|
||||
log "Adding user $user..."
|
||||
[ "$pass" == "" ] && pass=generate_password
|
||||
|
||||
if [[ "$args" != *nohome* ]]; then
|
||||
/usr/sbin/useradd --password `openssl passwd -crypt $pass` --create-home $user --shell /bin/bash
|
||||
/usr/sbin/useradd --password "$(openssl passwd -crypt "$pass")" --create-home "$user" --shell /bin/bash
|
||||
else
|
||||
/usr/sbin/useradd --password `openssl passwd -crypt $pass` $user --shell /bin/bash
|
||||
/usr/sbin/useradd --password "$(openssl passwd -crypt "$pass")" "$user" --shell /bin/bash
|
||||
fi
|
||||
fi
|
||||
}
|
||||
@ -415,7 +351,7 @@ run_as () {
|
||||
log "$cmd"
|
||||
# sudo -u $user -H -s /bin/bash -c "$cmd"
|
||||
# sudo -u $user -s /bin/bash -i "$cmd"
|
||||
su -c "$cmd" -s /bin/bash $user
|
||||
su -c "$cmd" -s /bin/bash "$user"
|
||||
}
|
||||
|
||||
#
|
||||
@ -438,7 +374,7 @@ add_line () {
|
||||
# Write a warning if user is not root.
|
||||
#
|
||||
warn_if_not_root () {
|
||||
uid=`id -u` && [ "$uid" = "0" ] ||
|
||||
uid="$(id -u)" && [ "$uid" = "0" ] ||
|
||||
{ echo "WARNING: You are NOT running this script as 'root'. You might want to consider that..."; }
|
||||
}
|
||||
|
||||
@ -446,7 +382,7 @@ warn_if_not_root () {
|
||||
# Stops the execution of the script if user is not root.
|
||||
#
|
||||
fail_if_not_root () {
|
||||
uid=`id -u` && [ "$uid" = "0" ] ||
|
||||
uid="$(id -u)" && [ "$uid" = "0" ] ||
|
||||
{ echo "You must run this as 'root'. Exiting."; exit 1; }
|
||||
}
|
||||
|
||||
@ -473,8 +409,8 @@ set_installed () {
|
||||
local args=$*
|
||||
local name=${args//[ \/:@]/-}
|
||||
|
||||
mkdir -p ~/.shoestrap/installed
|
||||
touch ~/.shoestrap/installed/$name
|
||||
mkdir -p "$HOME/.shoestrap/installed"
|
||||
touch "$HOME/.shoestrap/installed/$name"
|
||||
}
|
||||
|
||||
#
|
||||
|
@ -8,7 +8,7 @@
|
||||
##############################################################
|
||||
|
||||
# Get current directory for future use in links
|
||||
cd $(dirname $0)
|
||||
cd "$(dirname "$0")" || { echo "Could not change directory to $0"; exit 1;}
|
||||
PROJECT_DIR=$(pwd)
|
||||
|
||||
detect_package_manager
|
||||
|
5
recipes/default/bin
Normal file → Executable file
5
recipes/default/bin
Normal file → Executable file
@ -1,6 +1,7 @@
|
||||
#! /bin/bash
|
||||
|
||||
for f in $DEFAULT_ASSETS_PATH/* ; do
|
||||
try_link "$f" "$USER_BIN/$(basename $f)"
|
||||
# Link all user specific scripts to user bin
|
||||
for f in "$DEFAULT_ASSETS_PATH"/* ; do
|
||||
try_link "$f" "$USER_BIN/$(basename "$f")"
|
||||
done
|
||||
|
||||
|
10
recipes/default/build-fish
Normal file → Executable file
10
recipes/default/build-fish
Normal file → Executable file
@ -2,13 +2,13 @@
|
||||
|
||||
log "Compiling and installing fish-shell"
|
||||
|
||||
local fish_shell_dir=$WORKSPACE/fish-shell
|
||||
fish_shell_dir="$WORKSPACE/fish-shell"
|
||||
|
||||
if [ ! -d $fish_shell_dir ]; then
|
||||
if [ ! -d "$fish_shell_dir" ]; then
|
||||
log "Cloning fish-shell"
|
||||
git clone https://github.com/fish-shell/fish-shell $fish_shell_dir
|
||||
git clone https://github.com/fish-shell/fish-shell "$fish_shell_dir"
|
||||
else
|
||||
(cd $fish_shell_dir && git pull)
|
||||
(cd "$fish_shell_dir" && git pull)
|
||||
fi
|
||||
|
||||
(cd $fish_shell_dir && ./configure && make && sudo make install)
|
||||
(cd "$fish_shell_dir" && ./configure && make && sudo make install)
|
||||
|
10
recipes/default/build-neovim
Normal file → Executable file
10
recipes/default/build-neovim
Normal file → Executable file
@ -22,13 +22,13 @@ if command_exist pip3 ; then
|
||||
sudo pip3 install neovim
|
||||
fi
|
||||
|
||||
local neovim_dir=$WORKSPACE/neovim
|
||||
neovim_dir="$WORKSPACE/neovim"
|
||||
|
||||
if [ ! -d $neovim_dir ]; then
|
||||
if [ ! -d "$neovim_dir" ]; then
|
||||
log "Cloning neovim"
|
||||
git clone https://github.com/neovim/neovim $neovim_dir
|
||||
git clone https://github.com/neovim/neovim "$neovim_dir"
|
||||
else
|
||||
(cd $neovim_dir && git fetch)
|
||||
(cd "$neovim_dir" && git fetch)
|
||||
fi
|
||||
|
||||
(cd $neovim_dir && git checkout stable && make && sudo make install)
|
||||
(cd "$neovim_dir" && git checkout stable && make && sudo make install)
|
||||
|
16
recipes/default/build-vim
Normal file → Executable file
16
recipes/default/build-vim
Normal file → Executable file
@ -1,6 +1,6 @@
|
||||
#!/bin/bash
|
||||
|
||||
local vim_dir="$WORKSPACE/vim"
|
||||
vim_dir="$WORKSPACE/vim"
|
||||
|
||||
# Get the build dependencies
|
||||
if [ "$PACKAGE_MANAGER" == 'apt-get' ]; then
|
||||
@ -9,17 +9,17 @@ fi
|
||||
# TODO: Add pacman support
|
||||
|
||||
# Build latest vim
|
||||
if [ ! -d $vim_dir ]; then
|
||||
if [ ! -d "$vim_dir" ]; then
|
||||
log "Cloning vim"
|
||||
git clone https://github.com/vim/vim.git $vim_dir
|
||||
git clone https://github.com/vim/vim.git "$vim_dir"
|
||||
else
|
||||
(cd $vim_dir && git fetch)
|
||||
(cd "$vim_dir" && git fetch)
|
||||
fi
|
||||
|
||||
function conf_build_and_install() {
|
||||
# Get latest tagged source code
|
||||
latest_tag=`git describe --tags`
|
||||
git checkout $latest_tag
|
||||
latest_tag=$(git describe --tags)
|
||||
git checkout "$latest_tag"
|
||||
|
||||
# Configure vim with ruby, python and GTK
|
||||
./configure --with-features=huge \
|
||||
@ -32,8 +32,8 @@ function conf_build_and_install() {
|
||||
# Install newly compiled vim
|
||||
sudo make install
|
||||
# Link vi to vim out of convenience
|
||||
vim_path=$(which vim)
|
||||
sudo ln -s $vim_path ${vim_path:0:(-1)}
|
||||
vim_path=$(command -v vim)
|
||||
sudo ln -s "$vim_path" "${vim_path:0:(-1)}"
|
||||
}
|
||||
|
||||
(cd $vim_dir && conf_build_and_install)
|
||||
|
0
recipes/default/dotfiles
Normal file → Executable file
0
recipes/default/dotfiles
Normal file → Executable file
12
recipes/default/fish
Normal file → Executable file
12
recipes/default/fish
Normal file → Executable file
@ -1,8 +1,10 @@
|
||||
#! /bin/bash
|
||||
|
||||
mkdir -p $XDG_CONFIG_HOME/fish
|
||||
touch $XDG_CONFIG_HOME/fish/config.fish
|
||||
# Link and add source all synced fish configs
|
||||
|
||||
try_link $DEFAULT_ASSETS_PATH $XDG_CONFIG_HOME/fish/synced
|
||||
add_line "set -gx fish_synced_dir $XDG_CONFIG_HOME/fish/synced " $XDG_CONFIG_HOME/fish/config.fish
|
||||
add_line "source $XDG_CONFIG_HOME/fish/synced/init.fish " $XDG_CONFIG_HOME/fish/config.fish
|
||||
mkdir -p "$XDG_CONFIG_HOME/fish"
|
||||
touch "$XDG_CONFIG_HOME/fish/config.fish"
|
||||
|
||||
try_link "$DEFAULT_ASSETS_PATH" "$XDG_CONFIG_HOME/fish/synced"
|
||||
add_line "set -gx fish_synced_dir $XDG_CONFIG_HOME/fish/synced " "$XDG_CONFIG_HOME/fish/config.fish"
|
||||
add_line "source $XDG_CONFIG_HOME/fish/synced/init.fish " "$XDG_CONFIG_HOME/fish/config.fish"
|
||||
|
2
recipes/default/git
Normal file → Executable file
2
recipes/default/git
Normal file → Executable file
@ -10,6 +10,6 @@ git config --global diff.tool vimdiff
|
||||
# Suppress launching prompt
|
||||
git config --global difftool.prompt false
|
||||
# Create global ignore file
|
||||
mkdir -p $XDG_CONFIG_HOME/git/
|
||||
mkdir -p "$XDG_CONFIG_HOME/git/"
|
||||
git config --global core.excludesfile "$XDG_CONFIG_HOME/git/exclude_global"
|
||||
try_link "exclude_global" "$XDG_CONFIG_HOME/git/exclude_global"
|
||||
|
@ -1,12 +1,13 @@
|
||||
#!/bin/bash
|
||||
|
||||
version="1.5.1"
|
||||
# Installs golang from the web
|
||||
|
||||
version="1.13.3"
|
||||
if [[ "$UNAME_STR" == "Darwin" ]]; then
|
||||
wget -P $TMP_DIR/ http://golang.org/dl/go${version}.darwin-amd64-osx10.8.pkg
|
||||
installer -pkg $TMP_DIR/go${version}.darwin-amd64-osx10.8.pkg
|
||||
wget -P "$TMP_DIR/" "http://golang.org/dl/go${version}.darwin-amd64-osx10.8.pkg"
|
||||
installer -pkg "$TMP_DIR/go${version}.darwin-amd64-osx10.8.pkg"
|
||||
elif [[ "$UNAME_STR" == "Linux" ]]; then
|
||||
wget -P $TMP_DIR/ http://golang.org/dl/go${version}.linux-amd64.tar.gz
|
||||
wget -P "$TMP_DIR/" "http://golang.org/dl/go${version}.linux-amd64.tar.gz"
|
||||
# Do something
|
||||
echo "**** Install from $TMP_DIR/go${version}.linux-amd64.tar.gz"
|
||||
fi
|
||||
|
6
recipes/default/mac-bin
Normal file → Executable file
6
recipes/default/mac-bin
Normal file → Executable file
@ -1,6 +1,8 @@
|
||||
#! /bin/bash
|
||||
|
||||
for f in $DEFAULT_ASSETS_PATH/* ; do
|
||||
try_link "$f" "$USER_BIN/$(basename $f)"
|
||||
# Try to link all local bin assets specific to macOS
|
||||
|
||||
for f in "$DEFAULT_ASSETS_PATH"/* ; do
|
||||
try_link "$f" "$USER_BIN/$(basename "$f")"
|
||||
done
|
||||
|
||||
|
@ -1,12 +1,14 @@
|
||||
#! /bin/bash
|
||||
|
||||
sudo_package_update
|
||||
packages="tmux htop curl wget mercurial ctags tig pv jq fish mosh bash-completion doxygen shellcheck"
|
||||
|
||||
# This now installs a lot of language specific stuff from python, gradle, to go.
|
||||
# Should consider pulling these into different recipes that are dependent on the environment
|
||||
# that I wish to bootstrap. If not a dev environment, I can trim out some of this.
|
||||
|
||||
# Packages that are pretty much the same treatment or names in all systems
|
||||
packages="tmux htop curl wget mercurial ctags tig pv jq fish mosh bash-completion doxygen shellcheck"
|
||||
|
||||
# Manager specific packages
|
||||
case "$PACKAGE_MANAGER" in
|
||||
"port")
|
||||
@ -25,7 +27,7 @@ case "$PACKAGE_MANAGER" in
|
||||
packages="$packages neovim py-neovim py27-neovim py37-neovim"
|
||||
|
||||
# Install packages
|
||||
sudo_package $packages
|
||||
sudo_package "$packages"
|
||||
|
||||
# Select defaults
|
||||
sudo port select --set python python27
|
||||
@ -35,10 +37,12 @@ case "$PACKAGE_MANAGER" in
|
||||
sudo port select --set ipython2 py27-ipython
|
||||
sudo port select --set ipython3 py37-ipython
|
||||
sudo port select --set pip pip27
|
||||
sudo port select --set tox tox27
|
||||
sudo port select --set flake8 flake8-27
|
||||
sudo port select --set virtualenv virtualenv27
|
||||
try_link $(which pip-3.7) "$USER_BIN/pip3"
|
||||
sudo port select --set pip2 pip27
|
||||
sudo port select --set pip3 pip37
|
||||
# Use py3 versions for utilities
|
||||
sudo port select --set tox tox37
|
||||
sudo port select --set flake8 flake8-37
|
||||
sudo port select --set virtualenv virtualenv37
|
||||
;;
|
||||
"apt-get")
|
||||
if [ -n "$(apt-cache policy silversearcher-ag)" ] ; then
|
||||
@ -53,6 +57,6 @@ case "$PACKAGE_MANAGER" in
|
||||
# No python3-tox for ubuntu
|
||||
sudo pip3 install tox
|
||||
|
||||
sudo_package $packages
|
||||
sudo_package "$packages"
|
||||
;;
|
||||
esac
|
||||
|
4
recipes/default/salesforce
Normal file → Executable file
4
recipes/default/salesforce
Normal file → Executable file
@ -18,7 +18,7 @@ if $install_fcli ; then
|
||||
recipe 'force-cli'
|
||||
fi
|
||||
|
||||
for f in $DEFAULT_ASSETS_PATH/* ; do
|
||||
try_link "$f" "$USER_BIN/$(basename $f)"
|
||||
for f in "$DEFAULT_ASSETS_PATH"/* ; do
|
||||
try_link "$f" "$USER_BIN/$(basename "$f")"
|
||||
done
|
||||
|
||||
|
10
recipes/default/vim-settings
Normal file → Executable file
10
recipes/default/vim-settings
Normal file → Executable file
@ -1,12 +1,12 @@
|
||||
#! /bin/bash
|
||||
VIM_SETTINGS_DIR=$WORKSPACE/vim-settings
|
||||
vim_settings_dir="$WORKSPACE/vim-settings"
|
||||
|
||||
# Clone vundle if not done already
|
||||
if [ ! -d $VIM_SETTINGS_DIR ]; then
|
||||
if [ ! -d "$vim_settings_dir" ]; then
|
||||
log "Cloning vim-settings"
|
||||
git clone https://github.com/ViViDboarder/vim-settings $VIM_SETTINGS_DIR
|
||||
(cd $VIM_SETTINGS_DIR && ./vim-sync-append.sh)
|
||||
git clone https://github.com/ViViDboarder/vim-settings "$vim_settings_dir"
|
||||
(cd "$vim_settings_dir" && ./vim-sync-append.sh)
|
||||
else
|
||||
log "Updating vim-settings"
|
||||
(cd $VIM_SETTINGS_DIR && git pull)
|
||||
(cd "$vim_settings_dir" && git pull)
|
||||
fi
|
||||
|
Loading…
Reference in New Issue
Block a user