obosdi/archdi

206 lines
5.1 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)
2019-02-02 14:23:43 -07:00
apptitle="Arch Linux Desktop Install (archdi) - Version: 2019.02.02.22.23.36 (GPLv3)"
version="2019.02.02.22.23.36"
2015-08-20 16:21:43 -06:00
cachedir=~/.cache/archdi
2015-08-20 17:15:14 -06:00
lastverurl1=http://archdi.sourceforge.net/version
2015-08-20 17:38:11 -06:00
lastverurl2=https://raw.githubusercontent.com/MatMoul/archdi/master/version
2015-08-20 17:15:14 -06:00
binurl1=archdi.sourceforge.net/archdi
binurl2=matmoul.github.io/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
2017-02-04 14:18:19 -07:00
pkgurl1=http://archdi.sourceforge.net/archdi-pkg
pkgurl2=https://raw.githubusercontent.com/MatMoul/archdi-pkg/master/pkg.tar
2015-08-20 16:21:43 -06:00
help(){
2015-12-20 08:19:21 -07:00
echo "-h | --help : this screen"
echo "-i | --install : install"
echo "-l | --local dir : run local archdi-pkg dir"
2015-12-20 08:19:21 -07:00
echo "-t | --test githubuser branch : launch a forked branch"
echo "no args : start archdi"
2015-08-20 16:21:43 -06:00
}
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
2017-02-04 14:18:19 -07:00
if [ ! "$pkgdir" = "" ]; then
cp -r $pkgdir/* . >/dev/null
2017-02-04 14:18:19 -07:00
else
if [ "$pkgurl" == "" ]; then
wget -O lib $liburl 2>/dev/null
else
echo ""
echo "Downloading packages..."
wget -O pkg.tar $pkgurl 2>/dev/null
tar -xf pkg.tar
fi
2017-02-04 14:18:19 -07:00
fi
2015-08-20 16:21:43 -06:00
chmod 755 lib 2>/dev/null
if [ "$chrootoption" = "true" ]; then
./lib --chroot
2016-03-16 14:23:46 -06:00
if [ ! "$?" = "0" ]; then
archdi --branch master
fi
2015-08-20 16:21:43 -06:00
else
if [ ! "$pkgdir" = "" ]; then
sed -i "/apptitle=/c\apptitle=\"Arch Linux Desktop Install (archdi) - local: $pkgdir (GPLv3)\"" lib
sed -i "/baseurl=/c\baseurl=$pkgdir" lib
2015-08-29 15:03:34 -06:00
./lib --root
2016-03-16 14:23:46 -06:00
if [ ! "$?" = "0" ]; then
archdi --branch master
fi
2015-08-29 15:03:34 -06:00
else
if [ "$branchoption" = "" ]; then
./lib --root
if [ ! "$?" = "0" ]; then
archdi --branch master
fi
else
sed -i "/apptitle=/c\apptitle=\"Arch Linux Desktop Install (archdi) - Branch: $branchoption (GPLv3)\"" lib
sed -i "/baseurl=/c\baseurl=https://raw.githubusercontent.com/$githubuser/archdi-pkg/$branchoption" lib
./lib --root
if [ ! "$?" = "0" ]; then
archdi --branch master
fi
2016-03-16 14:23:46 -06:00
fi
2015-08-29 15:03:34 -06:00
fi
2015-08-20 16:21:43 -06:00
fi
2015-08-20 16:21:43 -06:00
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 18:00:09 -06:00
lastverurl=$lastverurl1
2015-08-20 18:03:34 -06:00
lastver=$(curl $lastverurl)
if [ "$?" = "0" ] && [ "${#lastver}" = "19" ]; then
2015-08-20 17:15:14 -06:00
binurl=$binurl1
2015-08-20 17:01:30 -06:00
liburl=$liburl1
2017-02-04 14:18:19 -07:00
pkgurl=$pkgurl1
2015-08-20 17:01:30 -06:00
else
2015-08-20 18:00:09 -06:00
lastverurl=$lastverurl2
2015-08-20 18:03:34 -06:00
lastver=$(curl $lastverurl)
if [ "$?" = "0" ] && [ "${#lastver}" = "19" ]; then
2015-08-20 17:15:14 -06:00
binurl=$binurl2
2015-08-20 17:01:30 -06:00
liburl=$liburl2
2017-02-04 14:18:19 -07:00
pkgurl=$pkgurl2
2015-08-20 17:01:30 -06:00
else
exit 1
fi
fi
2015-08-20 16:21:43 -06:00
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 ?"
2015-08-20 17:15:14 -06:00
read -p "Install missing dependencies ? (Y/n)" choice
case "$choice" in
n|N ) exit 1;;
esac
pacman -S --needed wget libnewt
2015-08-20 16:21:43 -06:00
fi
echo ""
echo "Checking bin version..."
2015-08-20 17:18:33 -06:00
chkupgrade
2015-08-20 16:21:43 -06:00
}
chkupgrade(){
2015-08-20 17:15:14 -06:00
if [ "$0" = "/usr/bin/archdi" ]; then
2015-08-20 18:03:34 -06:00
if [ ! "$version" = "$lastver" ]; 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
2015-08-20 17:15:14 -06:00
wget $binurl
2015-08-20 16:21:43 -06:00
sh archdi -i
exit 0
fi
fi
fi
}
2015-08-29 14:49:11 -06:00
branchoption=""
2015-08-20 16:21:43 -06:00
while (( "$#" )); do
case $1 in
-h|--help) help
exit 0;;
-i|--install) install
exit 0;;
--chroot) chrootoption="true";;
2015-12-20 08:19:21 -07:00
-b | --branch)
2015-08-29 14:49:11 -06:00
shift
liburl1=https://raw.githubusercontent.com/MatMoul/archdi-pkg/$1/lib
liburl2=https://raw.githubusercontent.com/MatMoul/archdi-pkg/$1/lib
2017-02-04 14:18:19 -07:00
pkgurl1=""
pkgurl2=""
2015-08-29 14:49:11 -06:00
branchoption="$1"
2015-12-20 08:19:21 -07:00
githubuser="MatMoul"
;;
-l | --local)
shift
apptitle="Arch Linux Desktop Install (archdi) - Version: local ($1)"
2019-02-02 14:23:43 -07:00
version="2019.02.02.22.23.36"
pkgdir="$1"
;;
2015-12-20 08:19:21 -07:00
-t | --test)
shift
liburl1=https://raw.githubusercontent.com/$1/archdi-pkg/$2/lib
liburl2=https://raw.githubusercontent.com/$1/archdi-pkg/$2/lib
2017-02-04 14:18:19 -07:00
pkgurl1=""
pkgurl2=""
2015-12-20 08:19:21 -07:00
branchoption="$2"
githubuser="$1"
2015-08-29 14:49:11 -06:00
;;
2015-08-20 16:21:43 -06:00
esac
shift
done
run