314 lines
6 KiB
Bash
314 lines
6 KiB
Bash
#!/bin/bash
|
|
|
|
|
|
# Ourobor.OS Fast Install (obos-fi)
|
|
# --------------------------------
|
|
# archdi author : MatMoul
|
|
# https://github.com/MatMoul
|
|
# http://sourceforge.net/u/matmoul
|
|
# obosdi author : LimePotato (Ouroboros)
|
|
# https://limepot.xyz/
|
|
# https://git.ouroboros.group/Ouroboros/
|
|
# https://git.ouroboros.group/LimePotato/
|
|
#
|
|
# project : https://git.ouroboros.group/Ouroboros/obos-fi
|
|
#
|
|
# license : LGPL-3.0 (http://opensource.org/licenses/lgpl-3.0.html)
|
|
|
|
|
|
|
|
apptitle="Ourobor.OS Desktop Install (obosdi) - Version: 0.0.1 (GPLv3)"
|
|
baseurl=https://git.ouroboros.group/Ouroboros/obosdi-pkg/raw/branch/master
|
|
cachedir=~/.cache/obosdi
|
|
|
|
|
|
cat << EOF > dialog.obosfi
|
|
use_shadow = OFF
|
|
title_color = (BLACK,WHITE,OFF)
|
|
button_label_active_color = (WHITE,BLUE,ON)
|
|
button_label_inactive_color = (BLACK,WHITE,OFF)
|
|
tag_color = (BLACK,WHITE,OFF)
|
|
tag_selected_color = (WHITE,BLUE,ON)
|
|
tag_key_color = (BLACK,WHITE,OFF)
|
|
tag_key_selected_color = (WHITE,BLUE,ON)
|
|
check_color = tag_color
|
|
check_selected_color = tag_selected_color
|
|
EOF
|
|
export DIALOGRC="dialog.obosfi"
|
|
|
|
|
|
# $1: path
|
|
menu(){
|
|
require $1 755
|
|
$cachedir/$1
|
|
if [ $? = 0 ]; then
|
|
menu $1
|
|
fi
|
|
}
|
|
|
|
|
|
# $1: path
|
|
script(){
|
|
require $1 755
|
|
$cachedir/$1
|
|
}
|
|
|
|
|
|
# $1: pacman packages
|
|
# $2: aur packages
|
|
instpkg(){
|
|
if [ ! "$1" = "" ]; then
|
|
clear
|
|
echo "# pacman -S --needed $1"
|
|
pacman -S --needed $1
|
|
pressanykey
|
|
fi
|
|
if [ ! "$2" = "" ]; then
|
|
if [ -f /usr/bin/trizen ]; then
|
|
clear
|
|
echo "# sudo -u aurbuilder trizen -S --needed $2"
|
|
sudo -u aurbuilder trizen -S --needed $2
|
|
pressanykey
|
|
else
|
|
if [ -f /usr/bin/yay ]; then
|
|
clear
|
|
echo "# sudo -u aurbuilder yay -S --needed $2"
|
|
sudo -u aurbuilder yay -S --needed $2
|
|
pressanykey
|
|
else
|
|
if [ -f /usr/bin/aurman ]; then
|
|
clear
|
|
echo "# sudo -u aurbuilder aurman -S --needed $2"
|
|
sudo -u aurbuilder aurman -S --needed $2
|
|
pressanykey
|
|
else
|
|
if [ -f /usr/bin/yaourt ]; then
|
|
clear
|
|
echo "# sudo -u aurbuilder yaourt -S --needed $2"
|
|
sudo -u aurbuilder yaourt -S --needed $2
|
|
pressanykey
|
|
else
|
|
echo "To install AUR packages, you need to install an aurhelper in updates menu !"
|
|
fi
|
|
fi
|
|
fi
|
|
fi
|
|
fi
|
|
}
|
|
|
|
|
|
# $1: string
|
|
# $2: [title]
|
|
choosepkg(){
|
|
if [ "$2" = "" ]; then
|
|
title=$1
|
|
else
|
|
title=$2
|
|
fi
|
|
options=()
|
|
items=$(pacman -Ssq $1)
|
|
for item in $items; do
|
|
options+=("$item" "" off)
|
|
done
|
|
sel=$(dialog --backtitle "$apptitle" --title "$title" --cancel-button "Back" --checklist "" 0 0 0 \
|
|
"${options[@]}" \
|
|
3>&1 1>&2 2>&3)
|
|
if [ ! "$?" = "0" ]; then
|
|
return 1
|
|
fi
|
|
for itm in $sel; do
|
|
pkg="$pkg $(echo $itm | sed 's/"//g')"
|
|
done
|
|
instpkg "$pkg" "$aurpkg"
|
|
return 0
|
|
}
|
|
|
|
|
|
# $1: string
|
|
# $2: [title]
|
|
chooseaurpkg(){
|
|
if [ "$2" = "" ]; then
|
|
title=$1
|
|
else
|
|
title=$2
|
|
fi
|
|
options=()
|
|
if [ -f /usr/bin/trizen ]; then
|
|
items=$(trizen -Ssq $1)
|
|
else
|
|
if [ -f /usr/bin/yay ]; then
|
|
items=$(yay -Ssq $1)
|
|
else
|
|
if [ -f /usr/bin/aurman ]; then
|
|
items=$(aurman -Ssq $1)
|
|
else
|
|
if [ -f /usr/bin/yaourt ]; then
|
|
items=$(yaourt -Ssq $1)
|
|
fi
|
|
fi
|
|
fi
|
|
fi
|
|
for item in $items; do
|
|
options+=("$item" "" off)
|
|
done
|
|
sel=$(dialog --backtitle "$apptitle" --title "$title" --cancel-button "Back" --checklist "" 0 0 0 \
|
|
"${options[@]}" \
|
|
3>&1 1>&2 2>&3)
|
|
if [ ! "$?" = "0" ]; then
|
|
return 1
|
|
fi
|
|
for itm in $sel; do
|
|
aurpkg="$aurpkg $(echo $itm | sed 's/"//g')"
|
|
done
|
|
instpkg "$pkg" "$aurpkg"
|
|
return 0
|
|
}
|
|
|
|
|
|
# $1: path
|
|
# $2: chmod
|
|
require(){
|
|
if [ ! -f "$cachedir/$1" ]; then
|
|
path=$(dirname $1)
|
|
mkdir -p $cachedir/$path 2> /dev/null
|
|
cd $cachedir/$path
|
|
curl -LO $baseurl/$1 2> /dev/null
|
|
fi
|
|
chmod $2 $cachedir/$1
|
|
cd $cachedir
|
|
}
|
|
|
|
|
|
# $1 : message
|
|
# $2 : args
|
|
confirm(){
|
|
dialog --backtitle "$apptitle" $2 --yesno "$1" 0 0
|
|
}
|
|
|
|
|
|
pressanykey(){
|
|
read -n1 -p "Press any key to continue."
|
|
}
|
|
|
|
|
|
# $1 : filename
|
|
editfile(){
|
|
editor=$EDITOR
|
|
if [ "$editor" == "" ]; then
|
|
editor="nano"
|
|
fi
|
|
if [ ! -f "/usr/bin/$editor" ]; then
|
|
editor="nano"
|
|
fi
|
|
echo "$editor $1"
|
|
$editor "$1"
|
|
}
|
|
|
|
|
|
# $1 : servicename
|
|
# $2 : [displayname]
|
|
svcstart(){
|
|
if [ "$2" = "" ]; then
|
|
displayname="$1"
|
|
else
|
|
displayname="$2 ($1)"
|
|
fi
|
|
if (confirm "Start $displayname service ?\n\nsystemctl start $1") then
|
|
clear
|
|
echo "systemctl start $1"
|
|
systemctl start $1
|
|
pressanykey
|
|
else
|
|
exit 1
|
|
fi
|
|
}
|
|
|
|
# $1 : servicename
|
|
# $2 : [displayname]
|
|
svcrestart(){
|
|
if [ "$2" = "" ]; then
|
|
displayname="$1"
|
|
else
|
|
displayname="$2 ($1)"
|
|
fi
|
|
if (confirm "Restart $displayname service ?\n\nsystemctl restart $1") then
|
|
clear
|
|
echo "systemctl restart $1"
|
|
systemctl restart $1
|
|
pressanykey
|
|
else
|
|
exit 1
|
|
fi
|
|
}
|
|
|
|
# $1 : servicename
|
|
# $2 : [displayname]
|
|
svcstop(){
|
|
if [ "$2" = "" ]; then
|
|
displayname="$1"
|
|
else
|
|
displayname="$2 ($1)"
|
|
fi
|
|
if (confirm "Stop $displayname service ?\n\nsystemctl stop $1") then
|
|
clear
|
|
echo "systemctl stop $1"
|
|
systemctl stop $1
|
|
pressanykey
|
|
else
|
|
exit 1
|
|
fi
|
|
}
|
|
|
|
# $1 : servicename
|
|
# $2 : [displayname]
|
|
svcenable(){
|
|
if [ "$2" = "" ]; then
|
|
displayname="$1"
|
|
else
|
|
displayname="$2 ($1)"
|
|
fi
|
|
if (confirm "Start $displayname service at boot ?\n\nsystemctl enable $1") then
|
|
clear
|
|
echo "systemctl enable $1"
|
|
systemctl enable $1
|
|
pressanykey
|
|
#else
|
|
# exit 1
|
|
fi
|
|
}
|
|
|
|
# $1 : servicename
|
|
# $2 : [displayname]
|
|
svcdisable(){
|
|
if [ "$2" = "" ]; then
|
|
displayname="$1"
|
|
else
|
|
displayname="$2 ($1)"
|
|
fi
|
|
if (confirm "Disable $displayname service at boot ?\n\nsystemctl disable $1") then
|
|
clear
|
|
echo "systemctl disable $1"
|
|
systemctl disable $1
|
|
pressanykey
|
|
#else
|
|
# exit 1
|
|
fi
|
|
}
|
|
|
|
|
|
|
|
while (( "$#" )); do
|
|
case $1 in
|
|
--root)
|
|
menu menu
|
|
exit 0
|
|
;;
|
|
--chroot)
|
|
require menu 755
|
|
sed -i "/options+=(\"Shutdown\" \"\")/d" menu
|
|
menu menu
|
|
exit 0
|
|
;;
|
|
esac
|
|
shift
|
|
done
|