aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Schneider <qsx@qsx.re>2017-02-26 17:07:18 +0100
committerThomas Schneider <qsx@qsx.re>2017-02-26 17:09:59 +0100
commit3218d7181246e04fa05225c73c9bf14acffcb0e1 (patch)
tree494e685e681ee34a7a2347eef5de96850d6c67ab
parentb59c490f9486ab17b11eff6b126c57f42ab2ca22 (diff)
Rewrite setup script in Python
Signed-off-by: Thomas Schneider <qsx@qsx.re>
-rwxr-xr-xsetup.py20
-rwxr-xr-xsetup.zsh17
2 files changed, 20 insertions, 17 deletions
diff --git a/setup.py b/setup.py
new file mode 100755
index 0000000..173a898
--- /dev/null
+++ b/setup.py
@@ -0,0 +1,20 @@
+#!/usr/bin/env python3
+
+import os
+import sys
+from glob import glob
+
+os.chdir(os.path.dirname(__file__))
+exit = 0
+
+for f in glob('dot.*'):
+ dst = os.path.expanduser('~/' + f[3:])
+ src = os.path.join(os.getcwd(), f)
+ try:
+ os.symlink(src, dst)
+ except FileExistsError:
+ if not os.path.samefile(src, dst):
+ print(dst + " exists and does not link do " + dst)
+ exit = 1
+
+sys.exit(exit)
diff --git a/setup.zsh b/setup.zsh
deleted file mode 100755
index 233a942..0000000
--- a/setup.zsh
+++ /dev/null
@@ -1,17 +0,0 @@
-#!/usr/bin/env zsh
-
-[[ $PWD = ~/.dotfiles ]] || exit 1
-
-if [[ $(uname -s) = FreeBSD ]]; then
- if [[ -x /compat/linux/bin/ln ]]; then
- LN=/compat/linux/bin/ln
- else
- echo "On FreeBSD and no GNU ln found, exiting"
- exit 1
- fi
-fi
-LN=${LN:-ln}
-
-for i in dot.*; do
- ${LN} -Ts .dotfiles/${i} ~/${i#dot}
-done