summarylogtreecommitdiffstats
path: root/clenv.sh
diff options
context:
space:
mode:
authorHans-Nikolai Viessmann2019-10-15 16:58:59 +0200
committerHans-Nikolai Viessmann2019-10-15 16:58:59 +0200
commit1667cef1df7fcb541f8409c66b4817bb6797c50a (patch)
tree76ddc2bc4ac7617597fbbe3e8bbac196c76d0737 /clenv.sh
parentac84c3a09b74042ba0f257a798055f9be926a37a (diff)
downloadaur-1667cef1df7fcb541f8409c66b4817bb6797c50a.tar.gz
add two scripts for better global usage
one script is a wrapper around clm, and detects where StdEnv is. The user can for instance copy StdEnv into their CWD, and clm will use this directly. the other script (clenv) allows to user to pro-actively copy StdEnv into their home directory.
Diffstat (limited to 'clenv.sh')
-rw-r--r--clenv.sh56
1 files changed, 56 insertions, 0 deletions
diff --git a/clenv.sh b/clenv.sh
new file mode 100644
index 000000000000..080a2b81928f
--- /dev/null
+++ b/clenv.sh
@@ -0,0 +1,56 @@
+#!/usr/bin/env bash
+
+# this script creates a copy of the current system-level
+# StdEnv files of the Clean distribution and places them
+# in the users home directory (under .local)
+
+_install_dir="$HOME/.local/lib"
+
+usage () {
+ echo "USAGE: clenv [cmd]" >&2
+ echo ""
+ echo "Commands: status, init, deinit"
+}
+
+if [ $# -lt 1 ]; then
+ usage
+ exit 0
+fi
+
+case $1 in
+ status)
+ if [ ! -d "$_install_dir/StdEnv" ]; then
+ echo "not initilised"
+ else
+ echo "initilised"
+ fi
+ ;;
+ init)
+ if [ -d "$_install_dir/StdEnv" ]; then
+ echo -n "already initilised, overwrite? [Y/n]: "
+ read -r yn
+ if [ "$yn" != "${yn#[Yy]}" ] ;then
+ rm -rf "$_install_dir/StdEnv"
+ cp -r /usr/lib/StdEnv "$_install_dir"
+ echo "done"
+ fi
+ else
+ [ -d "$_install_dir" ] || mkdir -p "$_install_dir"
+ cp -r /usr/lib/StdEnv "$_install_dir"
+ echo "done"
+ fi
+ ;;
+ deinit)
+ if [ ! -d "$_install_dir/StdEnv" ]; then
+ echo "not initilised, nothing to do :("
+ else
+ rm -rf "$_install_dir/StdEnv"
+ echo "done"
+ fi
+ ;;
+ *)
+ echo "unknown command..."
+ usage
+ exit 1
+ ;;
+esac