Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Tree: 2a529f534c
Fetching contributors…

Cannot retrieve contributors at this time

executable file 187 lines (174 sloc) 5.425 kB
#!/bin/sh
# vim:set et sw=2:
# Does various tasks involved with moving in (such as setting up a crontab and
# changing my login shell).
[ -z "$PATH" ] && PATH="$HOME/bin:/usr/local/bin:/usr/bin:/bin"
case "$PATH" in
"$HOME/bin:"*) ;;
*) PATH="$HOME/bin:$PATH" ;;
esac
hostname="`(hostname 2>/dev/null || cat /proc/sys/kernel/hostname)|sed -e 's/\..*//'`"
inpath() { [ -x "`which "$1" 2>/dev/null`" ]; }
if [ "x$1" = "x--cron" -o "x$1" = "x--quiet" ]; then
quiet=1; exec >/dev/null; shift
fi
if [ "x$1" = "x--root-only" ]; then
echo '--root-only has been removed' >&2
exit 1
fi
if [ ! -f "$HOME/. tpope" -o -r "$HOME/. tpope" ]; then
[ -f "$HOME/. tpope" ] || hidden=1
touch "$HOME/. tpope"
chmod 0000 "$HOME/. tpope"
fi
if [ ! -f "$HOME/.hushlogin" ]; then
touch "$HOME/.hushlogin"
hidden=1
fi
if [ ! -f "$HOME/.imaprc" ]; then
cat > "$HOME/.imaprc" <<EOF
I accept the risk
set mail-subdirectory Mail
EOF
hidden=1
fi
if inpath dcop && [ ! -f "$HOME/.kde/share/config/kdeglobals" ]; then
mkdir -p "$HOME/.kde/share/config"
cat > "$HOME/.kde/share/config/kdeglobals" <<EOF
[General]
TerminalApplication=\$HOME/bin/x-terminal-emulator
EOF
hidden=1
fi
[ -z "$hidden" ] || echo "Creating hidden files."
if inpath lynx && [ ! -f "$HOME/.lynx.cfg" ]; then
globalcfg="`lynx -dump lynxcfg: 2>/dev/null|sed -ne '/^References/,$p'|grep 'file://localhost/'|tail -1|sed -e 's,.*file://localhost,,'`"
[ -n "$globalcfg" ] || \
for f in /usr/local/lib/lynx.cfg /usr/local/etc/lynx.cfg /etc/lynx.cfg; do
[ ! -f "$f" ] || globalcfg="$f"
done
cat > "$HOME/.lynx.cfg" <<EOF
# ~/.lynx.cfg
INCLUDE:$globalcfg
ACCEPT_ALL_COOKIES:TRUE
DEFAULT_EDITOR:tpope sensible-editor
DEFAULT_USER_MODE:INTERMEDIATE
EMACS_KEYS_ALWAYS_ON:TRUE
EXTERNAL:http:sensible-browser %s:TRUE
EXTERNAL:file:sensible-browser %s:TRUE
SAVE_SPACE:~/dl
STARTFILE:http://www.google.com/
EOF
web=1
fi
if inpath elinks && [ ! -d "$HOME/.elinks" ]; then
mkdir "$HOME/.elinks"
cat > "$HOME/.elinks/elinks.conf" <<EOF
# ~/.elinks/elinks.conf
set terminal.xterm.colors = 1
set terminal.screen.colors = 1
set terminal.screen.block_cursor = 1
set terminal.screen.underline = 1
set terminal.screen.type = 1
set document.colors.use_document_colors = 1
set document.colors.vlink = "fuchsia"
set document.download.directory = "~/dl"
set document.plain.display_links = 1
EOF
web=1
elif inpath links && [ ! -d "$HOME/.links" -a ! -d "$HOME/.elinks" ]; then
mkdir "$HOME/.links"
cat > "$HOME/.links/links.cfg" <<EOF
# ~/.links/links.cfg
terminal "xterm" 0 0 1 us-ascii
terminal "screen" 0 0 1 us-ascii
download_dir "~/dl"
EOF
web=1
fi
for dir in .mozilla/firefox 'Library/Application Support/Firefox'; do
[ -d "$HOME/$dir" ] || continue
if [ -f "$HOME/$dir/profiles.ini" ]; then
subdirs="`cat "$HOME/$dir/profiles.ini"|grep '^Path='|sed -e 's/^Path=//'`"
else
subdirs="`ls -1 "$HOME/$dir"`"
fi
for subdir in $subdirs; do
subdir="$HOME/$dir/$subdir"
[ -d "$subdir" ] || continue
if [ ! -L "$subdir/user.js" ]; then
ln -s "$HOME/.netscape/user.js" "$subdir/user.js"
web=1
fi
if [ -d "$subdir/chrome" -a ! -e "$subdir/chrome/userContent.css" -a ! -L "$subdir/chrome/userContent.css" ]; then
ln -s "$HOME/.netscape/userContent.css" "$subdir/chrome/userContent.css"
web=1
fi
done
done
if [ ! -e "$HOME/dl" ]; then
if [ -d "$HOME/Downloads" ]; then
ln -s Downloads "$HOME/dl"
web=1
elif [ -d "$HOME/.mozilla" -o -f "$HOME/.lynx.cfg" -o -n "$web" ]; then
mkdir "$HOME/dl"
chmod 0755 "$HOME/dl"
web=1
fi
fi
[ -z "$web" ] || echo "Initializing browser configuration."
if inpath crontab && [ ! -f "$HOME/.sandbox" ]; then
crontab -l >/tmp/crontab.original.$$ 2>/dev/null
cron="$?"
crontab -l 2>&1 >/dev/null | grep "no crontab" >/dev/null && cron=n
if [ "$cron" = 0 ]; then
if grep 'tpope cron' /tmp/crontab.original.$$ >/dev/null; then
sed -ne '/tpope cron/,$p' /tmp/crontab.original.$$ | \
sed -ne '2,$p' > /tmp/crontab.custom.$$
cronmsg="Updating skeleton crontab."
else
cp /tmp/crontab.original.$$ /tmp/crontab.custom.$$
cronmsg="Inserting skeleton crontab."
fi
elif [ "$cron" = n ]; then
cp /tmp/crontab.original.$$ /tmp/crontab.custom.$$
cronmsg="Installing skeleton crontab."
fi
if [ "$cron" = 0 -o "$cron" = n ]; then
if [ -x /bin/bash ]; then
shell=/bin/bash
env=BASH_ENV
else
shell=/bin/sh
env=ENV
fi
[ -n "$RUBYLIB" ] || RUBYLIB="$HOME/src/ruby/lib:$HOME/.ruby/lib"
[ ! -f "$HOME/.ruby/lib/tpope.rb" ] || rubyopt="
RUBYOPT=rtpope"
cat >/tmp/crontab.template.$$ <<EOF
# -*- crontab -*- vim:set ft=crontab:
# crontab for $LOGNAME@$hostname
CRON=1
SHELL=$shell
$env=$HOME/.shrc
PATH=$HOME/bin:/usr/local/bin:/usr/bin:/bin
RUBYLIB=$RUBYLIB$rubyopt
RSYNC_RSH=ssh -axqoBatchMode=yes
20 */4 * * * tpope cron
EOF
cat /tmp/crontab.custom.$$ >> /tmp/crontab.template.$$
if ! cmp /tmp/crontab.template.$$ /tmp/crontab.original.$$ >/dev/null 2>&1; then
echo "$cronmsg"
crontab - < /tmp/crontab.template.$$
fi
rm /tmp/crontab.template.$$ /tmp/crontab.custom.$$
fi
rm /tmp/crontab.original.$$
fi
zsh="`grep 'zsh$' /etc/shells 2>/dev/null|head -1`"
if [ -x "$zsh" ] && grep "^$LOGNAME:" /etc/passwd >/dev/null && [ ! -f "$HOME/.sandbox" ]; then
if ! grep "^$LOGNAME:.*zsh" /etc/passwd >/dev/null ; then
echo "Changing login shell."
chsh -s "$zsh"
fi
fi
Jump to Line
Something went wrong with that request. Please try again.