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=
[ "$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; }
# 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; ;;
esac; done
if [ ! "$NAME" ]; then
read -e -p "Git author name: " NAME
if [[ ! "$NAME" ]]; then
read -e -p "Git author name [$USER]: " NAME
fi
[ "$NAME" ] || die "You must specify a Git author name"
if [ ! "$EMAIL" ]; then
read -e -p "Git author email: " EMAIL
[ "$NAME" ] || NAME="$USER"
if [[ ! "$EMAIL" ]]; then
read -e -p "Git author email [$USER@$(hostname)]: " EMAIL
fi
[ "$EMAIL" ] || die "You must specify a Git author email"
if [ ! "$IRCSET" ]; then
read -e -p "Would you like to set up irssi [Y/n]? " -i"n" yn
[ "$EMAIL" ] || EMAIL="$USER@$(hostname)"
if [[ ! "$IRCSET" ]]; then
read -e -p "Would you like to set up irssi [y/N]? " yn
case $yn in
[Yy]* )
read -e -p "irssi server: " -i"irc.freenode.net" IRCSERVER
read -e -p "irssi port: " -i"6667" IRCPORT
read -e -p "irssi nick: " -i"coward" IRCNICK
read -e -p "irssi psasword: " IRCPASS
read -e -p "irssi server [$IRCSERVER]: " IRCSERVER
read -e -p "irssi port [$IRCPORT]: " IRCPORT
read -e -p "irssi nick [$IRCNICK]: " IRCNICK
read -e -p "irssi psasword []: " IRCPASS
;;
esac
fi
fn_distro(){
if [ -f /etc/lsb-release ]; then
if [[ -f /etc/lsb-release ]]; then
os=$(lsb_release -s -d)
elif [ -f /etc/debian_version ]; then
elif [[ -f /etc/debian_version ]]; then
os="Debian $(cat /etc/debian_version)"
elif [ -f /etc/redhat-release ]; then
elif [[ -f /etc/redhat-release ]]; then
os=$(cat /etc/redhat-release)
else
os="$(uname -s) $(uname -r)"
@ -93,12 +97,24 @@ elif [[ "$UNAMESTR" == 'Darwin' ]]; then
true
fi
if [ ! -d "$DOTFILES" ]; then
if [[ ! -d "$DOTFILES" ]]; then
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!"
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
<"$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
<"$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