Commit Diff


commit - 4b0d8b80afbcbc8ba600373983a587dd8c172fc9
commit + 7cff7a60b13378c722196ac72466c20551fa7b0b
blob - e82d57b9b60f260632b5a15697f8b334f871fedb
blob + 23fd99e86c5731fbe988afac2f3f0171659ac559
--- current
+++ current
@@ -4,47 +4,42 @@
 #set -x
 
 ## Variables
+export	REL=6.4
+export	VERSION=64
 export	RELEASEPATH=/usr/rel
 export	KERNELSPATH=/kernels
-export	VERSION=64
-export  REL=6.4
 export	MIRROR="http://fastly.cdn.openbsd.org/"
 
+YO=$(hostname)
 ARCH=$(machine -a)
 HOST=$(hostname -s)
-YO=$(hostname)
-KERNEL=$(sysctl | grep -c kern.osversion=GENERIC.MP)
-PING=$(ping -c1 -w1 cisco.com | wc -l)
 LOCK="/tmp/current.lock"
+PING=$(ping -c1 -w1 cisco.com | wc -l)
+KERNEL=$(sysctl | grep -c kern.osversion=GENERIC.MP)
 
-## Check running
-if [ -e "${LOCK}" ]; then
-	printf "Already a ${0##*/} running, look at .lock on /tmp\\n"
-	exit 2
+if test "$(whoami)" != root; then
+	doas "$0" "$@"
+	exit $?
 fi
 
-touch ${LOCK}
-
-printf "[+] ${0##*/} - OpenBSD\\n"
-
 ## Check internet link
 if [ ! "${PING}" -lt "1" ]; then
-	printf "[+] Conexion OK.\\n"
+	printf ""
 else
-	printf "[+] Verifica la conexion a internet.\\n"
-	rm "${LOCK}"
+	printf "[+] No Internet.\\n"
 	exit 2
 fi
 
-check_root()
+check_lock()
 {
-	if test "$(whoami)" != root; then
-		doas "$0" "$@"
-		exit $?
+	if [ -e "${LOCK}" ]; then
+		printf "Already a ${0##*/} running, look at .lock on /tmp\\n"
+		exit 2
 	fi
+
+	touch ${LOCK}
 }
 
-## Checks misc
 check_path()
 {
 	if [ ! -d "${RELEASEPATH}" ]; then
@@ -138,6 +133,7 @@ check_new()
 	if [ "${DIFF}" -gt 1 ]; then
 		printf "[+] Starting upgrade...\\n"
 		instalation
+		rm "${LOCK}"
 	else
 		printf "[+] No updates on mirror ${MIRROR}\\n"
 		rm "${LOCK}"
@@ -251,13 +247,12 @@ firsttime()
 recordatorio()
 {
 	printf "[+] All done!\\n"
-	rm "${LOCK}"
 	exit
 }
 
 checks()
 {
-	check_root
+	check_lock
 	check_path
 	check_kernels_path
 	check_powerpc
@@ -287,16 +282,15 @@ usage()
 	echo "    -r    download the last release"
 	echo "    -f    install first time file (by default on -i and -F)"
 	echo
-	rm "${LOCK}"
 	exit 1
 }
 
-while getopts 'iFrf' arg; do
-	case ${arg} in
-	i)	checks ; check_new ;;
-	F)	checks ; force_new ;;
-	r)	checks ; download_rel ;;
-	f)  check_root ; firsttime ;;
+while getopts ':iFrf' opt; do
+	case ${opt} in
+	i)	checks && check_new ;;
+	F)	checks && force_new ;;
+	r)	checks && download_rel ;;
+	f)	firsttime ;;
 	*)	usage ;;
 	esac
 done