Permalink
Browse files

Make easy to config.

Just download "init" and run it.
  • Loading branch information...
sgkim126 committed Nov 26, 2013
1 parent b189ea9 commit 2c9f74742dcddb3437c01bdb6a74f4fd2e1da35c
Showing with 198 additions and 0 deletions.
  1. +54 −0 init
  2. +48 −0 make-git-env.sh
  3. +41 −0 make-linux-env.sh
  4. +55 −0 make-xorg-env.sh
54 init
@@ -0,0 +1,54 @@
#!/usr/bin/env bash

REPO_DIR=$HOME/repo
function confirm:message() {
MESSAGE=$1
if [[ -n "$MESSAGE" ]]
then
echo -n "$MESSAGE"
fi
echo -n "(y/n) "
while [ true ]
do
read -n 1
if [[ "$REPLY" = [Yy] ]]
then
echo ""
exit 0
elif [[ "$REPLY" = [Nn] ]]
then
echo ""
exit -1
fi
done
}

if (confirm:message 'Do you want to generate new SSH key?')
then
GITHUB_KEY=$HOME/.ssh/github.pub
if [ ! -d $HOME/.ssh/ ]
then
mkdir $HOME/.ssh
fi
ssh-keygen -t rsa -f $GITHUB_KEY || exit -1
echo "SSH Key is generated. Add below key to your github account."
cat $GITHUB_KEY.pub
read
ssh-add $GITHUB_KEY
unset GITHUB_KEY
fi

if [ ! -d $REPO_DIR ]
then
mkdir $REPO_DIR
fi
pushd $REPO_DIR
git clone git@github.com:sgkim126/vim_script.git || exit -1
ln -s $REPO_DIR/vim_script $HOME/.vim
ln -s $REPO_DIR/vim_script/vimrc $HOME/.vimrc
git clone git@github.com:sgkim126/config_script.git || exit -1
pushd config_script
bash make-linux-env.sh
popd

# vim:set ft=sh:
@@ -0,0 +1,48 @@
#!/usr/bin/env bash
CONFIG_PATH=`pwd`/`dirname $0`

function receive:message() {
MESSAGE=$1
if [[ -n "$MESSAGE" ]]
then
echo -n "$MESSAGE "
fi
while [ true ]
do
read -r
if [ -n "$REPLY" ]
then
return
fi
done
}

if [ ! -e $CONFIG_PATH/gitconfig ]
then
echo "ERROR: $CONFIG_PATH/gitconfig is not exist." 1>&2
exit -1
fi
if [ -e $HOME/.gitconfig ]
then
TARGET_FILE="$HOME/.gitconfig"
BACKUP_FILE="$HOME/gitconfig.backup"
echo "ERROR: $TARGET_FILE is already exist." 1>&2
echo " The old $TARGET_FILE will be copied to $BACKUP_FILE." 1>&2
mv $TARGET_FILE $BACKUP_FILE || exit -1
unset TARGET_FILE
unset BACKUP_FILE
fi

cp $CONFIG_PATH/gitconfig $HOME/.gitconfig

if [ ! $(git config --global user.name) ]
then
receive:message "Enter your name used for git commits."
git config --global user.name "$REPLY"
fi

if [ ! $(git config --global user.email) ]
then
receive:message "Enter your mail address used for git commits."
git config --global user.email "$REPLY"
fi
@@ -0,0 +1,41 @@
#!/usr/bin/env bash

CONFIG_PATH=`pwd`/`dirname $0`

function make_link:target() {
TARGET=$1
if [ ! -e $CONFIG_PATH/$TARGET ]
then
echo "ERROR: $CONFIG_PATH/$TARGET is not exist." 1>&2
exit -1
fi
if [ -e $HOME/.$TARGET ]
then
echo "ERROR: $HOME/.$TARGET is already exist." 1>&2
echo " The old $HOME/.$TARGET will be copied to $HOME/$TARGET.backup" 1>&2
mv $HOME/.$TARGET $HOME/$TARGET.backup || exit -1
fi
ln -s $CONFIG_PATH/$TARGET $HOME/.$TARGET || exit -1
unset TARGET
}

make_link:target bashrc
make_link:target profile
make_link:target subversion
make_link:target tmux.conf
make_link:target screenrc
make_link:target irssi

bash make-git-env.sh
bash make-xorg-env.sh

if [ -e $HOME/.root ]
then
echo "ERROR: $HOME/.root is already exist." 1>&2
echo " The old $HOME/.root will be copied to $HOME/root.backup" 1>&2
fi

mkdir $HOME/.root
mkdir $HOME/.root/lib
mkdir $HOME/.root/bin
# vim: set ft=sh
@@ -0,0 +1,55 @@
#!/usr/bin/env bash
CONFIG_PATH=`pwd`/`dirname $0`

function confirm:message() {
MESSAGE=$1
if [[ -n "$MESSAGE" ]]
then
echo -n "$MESSAGE"
fi
echo -n "(y/n) "
while [ true ]
do
read -n 1
if [[ "$REPLY" = [Yy] ]]
then
echo ""
exit 0
elif [[ "$REPLY" = [Nn] ]]
then
echo ""
exit -1
fi
done
}

function make_link:target() {
TARGET=$1
FROM_PATH="$CONFIG_PATH/xorg.conf.d"
TO_PATH='/usr/share/X11/xorg.conf.d/'
PREFIX='90-'
if [ ! -e $FROM_PATH/$TARGET ]
then
echo "ERROR: $FROM_PATH/$TARGET is not exist." 1>&2
exit -1
fi
if [ -e $TO_PATH/$TARGET ]
then
TARGET_FILE="$TO_PATH/$TO_PATH/$PREFIX$TARGET"
echo "ERROR: $TARGET_FILE is already exist." 1>&2
echo " The old $TARGET_FILE will be copied to $TARGET_FILE.backup." 1>&2
sudo mv $TARGET_FILE $TARGET_FILE.backup || exit -1
unset TARGET_FILE
fi
sudo ln -s $FROM_PATH/$TARGET $TO_PATH/$PREFIX$TARGET || exit -1
unset TARGET
unset FROM_PATH
unset TO_PATH
}

if (confirm:message 'Do you want to config xorg? It needs a root permision.')
then
make_link:target evoluent.conf
make_link:target kensington-slimblade.conf
fi
# vim: set ft=sh

0 comments on commit 2c9f747

Please sign in to comment.