Commit 682062ac9dc6

Vincent Demeester <vincent@sbr.pm>
2020-01-24 18:23:36
scripts: add up and some scripts 🏫
- up-redhat-vpn to connect to the vpn - up-home-manage to update home-manager Signed-off-by: Vincent Demeester <vincent@sbr.pm>
1 parent d036adf
Changed files (3)
pkgs/scripts/bin/up
@@ -0,0 +1,30 @@
+#!/usr/bin/env bash
+# -*- coding: utf-8 -*-
+# Author: Vincent Demeester <vincent@sbr.pm>
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+# up is my main command I wanna run in the morning, it should try to be smart
+DEFAULTS_ARGS="home-manager redhat-vpn"
+ARGS=${@}
+
+[[ -z ${@} ]] && ARGS="${DEFAULTS_ARGS}"
+
+for script in ${ARGS}; do
+    command -v up-$script 2>/dev/null >/dev/null || {
+        echo up-$script is missing
+    }
+done
+
+for script in ${ARGS}; do
+    up-$script
+done
pkgs/scripts/bin/up-home-manager
@@ -0,0 +1,48 @@
+#!/usr/bin/env bash
+# -*- coding: utf-8 -*-
+# Author: Vincent Demeester <vincent@sbr.pm>
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+# ---
+# up-home-manager updates home-manager
+update=no
+pull=yes
+
+TARGETS=switch
+
+set -ue
+while getopts "un" o; do
+    case "${o}" in
+        u)
+            update=yes
+            ;;
+        n)
+            pull=no
+            ;;
+        *)
+            echo "Invalid option"; exit 1;
+            ;;
+    esac
+done
+shift $((OPTIND-1))
+
+cd $HOME/.config/nixpkgs/
+if [[ "$pull" == "yes" ]]; then
+    git pull --rebase --autostash
+fi
+if [[ "$update" == "yes" ]]; then
+    TARGETS="update $TARGETS"
+fi
+
+make $TARGETS
+cd -
pkgs/scripts/bin/up-redhat-vpn
@@ -0,0 +1,17 @@
+#!/usr/bin/env bash
+# -*- coding: utf-8 -*-
+# Author: Vincent Demeester <vincent@sbr.pm>
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+# ---
+redhat-vpn