Skip to content

Commit b97c72c

Browse files
committed
Make update manual
1 parent aca533b commit b97c72c

File tree

1 file changed

+10
-20
lines changed

1 file changed

+10
-20
lines changed

lazy-connect.sh

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ lazy-connect - Shell function to fuzzy search an IPSec VPN by name
4343
4444
-i - Initialize lazy-connect.
4545
Stores the secret and VPN list to ~/.config/lazy-connect/
46+
-u - Update lazy-connect
4647
-h - Show this help
4748
EOF
4849
}
@@ -78,32 +79,17 @@ EOF
7879

7980
function _lazy_connect_update() {
8081
lazy_connect_dir=~/.lazy-connect
81-
seconds_in_7_days=$(echo $(((7 * 24) * 3600)))
82-
commit_epoch=$(git -C $lazy_connect_dir log -1 --format=%cd --date=format:"%s")
83-
now_epoch=$(date "+%s")
84-
diff=$(echo $(($now_epoch - $commit_epoch)))
85-
if [ $diff -ge $seconds_in_7_days ]; then
86-
echo -n "Do you want to update lazy-connect?(y/n) "
87-
read input
88-
case $input in
89-
Y|y)
90-
echo "Updating..."
91-
git -C $lazy_connect_dir pull origin master
92-
;;
93-
*)
94-
echo "Skipping update"
95-
;;
96-
esac
97-
fi
82+
git -C $lazy_connect_dir pull origin master
83+
echo -e "\n\nRun the below command or restart your shell."
84+
echo "$ source $lazy_connect_dir/lazy-connect.sh"
9885
}
9986

10087
function lazy-connect() {
88+
local OPTIND
10189
config_dir=~/.config/lazy-connect
10290
mkdir -p $config_dir
10391

104-
_lazy_connect_update
105-
106-
while getopts "ih" opt; do
92+
while getopts "ihu" opt; do
10793
case $opt in
10894
h)
10995
_lazy_connect_usage
@@ -113,6 +99,10 @@ function lazy-connect() {
11399
_lazy_connect_init
114100
return 0
115101
;;
102+
u)
103+
_lazy_connect_update
104+
return 0
105+
;;
116106
\?)
117107
echo "Invalid Option: -$OPTARG."
118108
_lazy_connect_usage

0 commit comments

Comments
 (0)