Add saved settings

This commit is contained in:
Chris Sexton 2015-03-05 15:02:38 -05:00
parent 52ef90ea45
commit 225b3f0b50
2 changed files with 38 additions and 17 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
dotfilesrc

54
setup.sh Normal file → Executable file
View File

@ -11,6 +11,10 @@ set -o pipefail
[ "$IRCPASS" ] || IRCPASS= [ "$IRCPASS" ] || IRCPASS=
[ "$DOTFILES" ] || DOTFILES="$HOME"/.dotfiles [ "$DOTFILES" ] || DOTFILES="$HOME"/.dotfiles
if [[ -f "$DOTFILES"/dotfilesrc ]]; then
source "$DOTFILES"/dotfilesrc
fi
die() { echo "$1" 1>&2 && show_help && [ "$2" ] && [ "$2" -ge 0 ] && exit "$2" || exit 1; } die() { echo "$1" 1>&2 && show_help && [ "$2" ] && [ "$2" -ge 0 ] && exit "$2" || exit 1; }
# Show help function to be used below # Show help function to be used below
@ -50,32 +54,32 @@ NARGS=-1; while [ "$#" -ne "$NARGS" ]; do NARGS=$#; case $1 in
shift && IRCPASS="$1" && IRCSET=1 && shift; ;; shift && IRCPASS="$1" && IRCSET=1 && shift; ;;
esac; done esac; done
if [ ! "$NAME" ]; then if [[ ! "$NAME" ]]; then
read -e -p "Git author name: " NAME read -e -p "Git author name [$USER]: " NAME
fi fi
[ "$NAME" ] || die "You must specify a Git author name" [ "$NAME" ] || NAME="$USER"
if [ ! "$EMAIL" ]; then if [[ ! "$EMAIL" ]]; then
read -e -p "Git author email: " EMAIL read -e -p "Git author email [$USER@$(hostname)]: " EMAIL
fi fi
[ "$EMAIL" ] || die "You must specify a Git author email" [ "$EMAIL" ] || EMAIL="$USER@$(hostname)"
if [ ! "$IRCSET" ]; then if [[ ! "$IRCSET" ]]; then
read -e -p "Would you like to set up irssi [Y/n]? " -i"n" yn read -e -p "Would you like to set up irssi [y/N]? " yn
case $yn in case $yn in
[Yy]* ) [Yy]* )
read -e -p "irssi server: " -i"irc.freenode.net" IRCSERVER read -e -p "irssi server [$IRCSERVER]: " IRCSERVER
read -e -p "irssi port: " -i"6667" IRCPORT read -e -p "irssi port [$IRCPORT]: " IRCPORT
read -e -p "irssi nick: " -i"coward" IRCNICK read -e -p "irssi nick [$IRCNICK]: " IRCNICK
read -e -p "irssi psasword: " IRCPASS read -e -p "irssi psasword []: " IRCPASS
;; ;;
esac esac
fi fi
fn_distro(){ fn_distro(){
if [ -f /etc/lsb-release ]; then if [[ -f /etc/lsb-release ]]; then
os=$(lsb_release -s -d) os=$(lsb_release -s -d)
elif [ -f /etc/debian_version ]; then elif [[ -f /etc/debian_version ]]; then
os="Debian $(cat /etc/debian_version)" os="Debian $(cat /etc/debian_version)"
elif [ -f /etc/redhat-release ]; then elif [[ -f /etc/redhat-release ]]; then
os=$(cat /etc/redhat-release) os=$(cat /etc/redhat-release)
else else
os="$(uname -s) $(uname -r)" os="$(uname -s) $(uname -r)"
@ -93,12 +97,24 @@ elif [[ "$UNAMESTR" == 'Darwin' ]]; then
true true
fi fi
if [ ! -d "$DOTFILES" ]; then if [[ ! -d "$DOTFILES" ]]; then
git clone git@git.chrissexton.org:cws/dotfiles.git "$DOTFILES" git clone git@git.chrissexton.org:cws/dotfiles.git "$DOTFILES"
elif [ ! -d "$DOTFILES"/files ]; then elif [[ ! -d "$DOTFILES"/files ]]; then
die "You must have a destination for the dotfiles repository!" die "You must have a destination for the dotfiles repository!"
fi fi
cat >"$DOTFILES"/dotfilesrc <<DOTFILESRC
NAME="$NAME"
EMAIL="$EMAIL"
IRCSET=1
IRCSERVER="$IRCSERVER"
IRCPORT="$IRCPORT"
IRCNICK="$IRCNICK"
IRCPASS="$IRCPASS"
DOTFILES="$DOTFILES"
DOTFILESRC
cat "$DOTFILES"/files/gitignore_global > "$HOME"/.gitignore_global cat "$DOTFILES"/files/gitignore_global > "$HOME"/.gitignore_global
<"$DOTFILES"/files/gitconfig sed -e "s/%NAME%/$NAME/" | sed -e "s/%EMAIL%/$EMAIL/" > "$HOME"/.gitconfig <"$DOTFILES"/files/gitconfig sed -e "s/%NAME%/$NAME/" | sed -e "s/%EMAIL%/$EMAIL/" > "$HOME"/.gitconfig
@ -122,3 +138,7 @@ cat "$DOTFILES"/files/tmux.sh > "$HOME"/bin/tmux.sh
mkdir -p "$HOME"/.irssi mkdir -p "$HOME"/.irssi
<"$DOTFILES"/files/irssiconfig sed -e "s/%PASSWORD%/$IRCPASS/" | sed -e "s/%NICK%/$IRCNICK/" | sed -e "s/%SERVER%/$IRCSERVER/" | sed -e "s/%PORT%/$IRCPORT/" > "$HOME"/.irssi/config <"$DOTFILES"/files/irssiconfig sed -e "s/%PASSWORD%/$IRCPASS/" | sed -e "s/%NICK%/$IRCNICK/" | sed -e "s/%SERVER%/$IRCSERVER/" | sed -e "s/%PORT%/$IRCPORT/" > "$HOME"/.irssi/config
if [[ ! -L "$HOME"/bin/setup.sh ]]; then
ln -s "$DOTFILES"/setup.sh "$HOME"/bin
fi