obosdi/archdi

161 lines
3.6 KiB
Text
Raw Normal View History

2015-08-20 16:21:43 -06:00
#!/bin/bash
# Arch Linux Desktop Install (archdi)
# -----------------------------------
# author : MatMoul
# https://github.com/MatMoul
# http://sourceforge.net/u/matmoul
# project : https://github.com/MatMoul/archdi
# http://sourceforge.net/projects/archdi/
# license : GPLv3 (http://opensource.org/licenses/GPL-3.0)
apptitle="Arch Linux Desktop Install (archdi) - Version: 2015.04.26.22.14.52 (GPLv3)"
2015-08-20 17:01:30 -06:00
version="2015.04.26.22.14.52"
2015-08-20 16:21:43 -06:00
cachedir=~/.cache/archdi
2015-08-20 17:01:30 -06:00
liburl1=http://archdi.sourceforge.net/archdi-lib
liburl2=https://raw.githubusercontent.com/MatMoul/archdi-pkg/master/lib
2015-08-20 16:21:43 -06:00
2015-08-20 17:01:30 -06:00
lastverurl1=https://raw.githubusercontent.com/MatMoul/archdi/master/version
lastverurl2=http://archdi.sourceforge.net/archdi/version
2015-08-20 16:21:43 -06:00
help(){
echo "-h | --help : this screen"
echo "-i | --install : install"
echo "no args : start setup"
}
install(){
dependencies
echo "Install $apptitle ..."
echo ""
chmod 755 $0 2>/dev/null
mv $0 /usr/bin/archdi 2>/dev/null
echo ""
echo "$apptitle is installed."
echo "type archdi to start."
}
run(){
dependencies
rm -R $cachedir 2>/dev/null
mkdir -p $cachedir 2>/dev/null
cd $cachedir 2>/dev/null
wget -O lib $liburl 2>/dev/null
chmod 755 lib 2>/dev/null
if [ "$chrootoption" = "true" ]; then
./lib --chroot
else
./lib --root
fi
cd 2>/dev/null
rm -R $cachedir 2>/dev/null
}
dependencies(){
needinstall="false"
clear
2015-08-20 16:38:44 -06:00
echo "Checking internet and server connexion ..."
2015-08-20 17:01:30 -06:00
lastver=$lastverurl1
lastversion=$(curl $lastver)
if [ "$?" = "0" ] && [ "${#lastversion}" = "19" ]; then
liburl=$liburl1
else
lastver=$lastverurl2
lastversion=$(curl $lastver)
if [ "$?" = "0" ] && [ "${#lastversion}" = "19" ]; then
liburl=$liburl2
else
exit 1
fi
fi
exit 0
liburl=$liburl1
2015-08-20 16:21:43 -06:00
if (curl $liburl 1>/dev/null 2>/dev/null) then
echo "Connexion OK."
else
2015-08-20 17:01:30 -06:00
liburl=$liburl2
if (curl $liburl 1>/dev/null 2>/dev/null) then
echo "Connexion OK."
else
echo "No connexion, please check your internet connexion !"
exit 1
fi
2015-08-20 16:21:43 -06:00
fi
echo ""
echo "Checking $apptitle dependencies :"
echo ""
if [ -e /usr/bin/wget ]; then
echo "wget : installed"
else
echo "wget : not installed"
needinstall="true"
fi
if [ -e /usr/bin/whiptail ]; then
echo "libnewt : installed"
else
echo "libnewt : not installed"
needinstall="true"
fi
if [ "$needinstall" = "true" ]; then
echo ""
echo "Install missing dependencies ?"
while read -n1 -p "[Y/N] :" -s yesno; do
if [[ $yesno = [YyNn] ]]; then
[[ $yesno = [Yy] ]] && yesno=1
[[ $yesno = [Nn] ]] && yesno=0
break
fi
echo ""
done
echo ""
if [ $yesno = 1 ]; then
pacman -S --needed wget libnewt
else
exit 1
fi
fi
echo ""
echo "Checking bin version..."
#chkupgrade
}
chkupgrade(){
if [ -f "/usr/bin/archdi" ]; then
2015-08-20 17:01:30 -06:00
#lastverurl=$lastverurl1
#chkver=$(curl $lastverurl)
#chkver=$version
2015-08-20 16:21:43 -06:00
#chkver=$(curl archdi.sourceforge.net/archdi/version)
2015-08-20 17:01:30 -06:00
if [ ! "$version" = "$lastversion" ]; then
2015-08-20 16:21:43 -06:00
if (whiptail --backtitle "$apptitle" --yesno "New version found !\n\nInstall last version ?" 0 0) then
cd /tmp
wget archdi.sourceforge.net/archdi
sh archdi -i
exit 0
fi
fi
fi
}
while (( "$#" )); do
case $1 in
-h|--help) help
exit 0;;
-i|--install) install
exit 0;;
#--rc) isrc=true
# liburl=$liburl-rc;;
--chroot) chrootoption="true";;
esac
shift
done
run