#!/bin/bash
ICON="/usr/share/fastrepo/icons/fastrepo.png"
### run as root ####
this_script_dir="$( cd "$( dirname "$0" )" && pwd )"
this_script="`basename $0`"
this_script_path_n_name="${this_script_dir}/${this_script}"
GUI_SU="pkexec env DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY"
if [ "$UID" != "0" ]; then
$GUI_SU bash $this_script_path_n_name; exit;
fi
if ! test -f "/etc/apt/sources.list" ; then
cp -rf "/etc/apt/sources.list" "/etc/apt/sources.list-" 
fi
action=$(yad \
--width=475 \
--height=95 \
--button="Cancel"!/usr/share/fastrepo/icons/cancel.svg:1 \
--button="Ok"!/usr/share/fastrepo/icons/ok.svg:0 \
--center \
--window-icon=$ICON \
--title='Fast Repo' \
--entry \
--text=$'Select a Repository From List' \
'ftp://ftp.nluug.nl' 'http://ftp.fau.de' 'http://distrib-coffee.ipsl.jussieu.fr' 'http://pclinuxos.mirror.wearetriple.com' 'http://pclinuxos.c3sl.ufpr.br' 'http://mirrors.uni-ruse.bg' 'http://ftp.cc.uoc.gr/mirrors' 'https://mirrors.cicku.me' 'https://mirror.freedif.org' 'http://ftp.jaist.ac.jp' 'https://mirror.webworld.ie' 'https://mirror.math.princeton.edu')
if [ -n "${action}" ];then
case $action in
'ftp://ftp.nluug.nl')
cp -rf "/usr/share/fastrepo/sources/apt/nluug" "/etc/apt/sources.list" 
cp -rf "/usr/share/fastrepo/sources/dnf/nluug.repo"  "/etc/repo.d/default.repo"
sleep 0.50 
$(yad --title="Fast Repo" \
--width=450 --height=100 --center --fixed \
--text=$"\nSelected repository: <span font_desc='Sans Bold Italic 10' foreground='#BE7F00'>ftp://ftp.nluug.nl</span>\n\nReload package manager to apply the repository changes.\n" \
--image="$ICON" \
--center \
--window-icon="$ICON" \
--button="Ok"!/usr/share/fastrepo/icons/ok.svg)
exit
 ;;
'http://ftp.fau.de')
cp -rf "/usr/share/fastrepo/sources/apt/fau" "/etc/apt/sources.list" 
cp -rf "/usr/share/fastrepo/sources/dnf/fau.repo"  "/etc/repo.d/default.repo"
sleep 0.50 
$(yad --title="Fast Repo" \
--width=450 --height=100 --center --fixed \
--text=$"\nSelected repository: <span font_desc='Sans Bold Italic 10' foreground='#BE7F00'>http://ftp.fau.de</span>\n\nReload package manager to apply the repository changes.\n" \
--image="$ICON" \
--center \
--window-icon="$ICON" \
--button="Ok"!/usr/share/fastrepo/icons/ok.svg)
 ;;
'http://pclinuxos.c3sl.ufpr.br')
cp -rf "/usr/share/fastrepo/sources/apt/ufpr" "/etc/apt/sources.list" 
cp -rf "/usr/share/fastrepo/sources/dnf/ufpr.repo"  "/etc/repo.d/default.repo"
sleep 0.50 
$(yad --title="Fast Repo" \
--width=450 --height=100 --center --fixed \
--text=$"\nSelected repository: <span font_desc='Sans Bold Italic 10' foreground='#BE7F00'>http://pclinuxos.c3sl.ufpr.br</span>\n\nReload package manager to apply the repository changes.\n" \
--image="$ICON" \
--center \
--window-icon="$ICON" \
--button="Ok"!/usr/share/fastrepo/icons/ok.svg)
exit
 ;;
'http://ftp.cc.uoc.gr/mirrors')
cp -rf "/usr/share/fastrepo/sources/apt/uoc" "/etc/apt/sources.list" 
cp -rf "/usr/share/fastrepo/sources/dnf/uoc.repo"  "/etc/repo.d/default.repo"
sleep 0.50 
$(yad --title="Fast Repo" \
--width=450 --height=100 --center --fixed \
--text=$"\nSelected repository: <span font_desc='Sans Bold Italic 10' foreground='#BE7F00'>http://ftp.cc.uoc.gr/mirrors</span>\n\nReload package manager to apply the repository changes.\n" \
--image="$ICON" \
--center \
--window-icon="$ICON" \
--button="Ok"!/usr/share/fastrepo/icons/ok.svg)
exit
 ;;
'http://mirrors.uni-ruse.bg')
cp -rf "/usr/share/fastrepo/sources/apt/uni-ruse" "/etc/apt/sources.list" 
cp -rf "/usr/share/fastrepo/sources/dnf/uni-ruse.repo"  "/etc/repo.d/default.repo"
sleep 0.50 
$(yad --title="Fast Repo" \
--width=450 --height=100 --center --fixed \
--text=$"\nSelected repository: <span font_desc='Sans Bold Italic 10' foreground='#BE7F00'>http://mirrors.uni-ruse.bg</span>\n\nReload package manager to apply the repository changes.\n" \
--image="$ICON" \
--center \
--window-icon="$ICON" \
--button="Ok"!/usr/share/fastrepo/icons/ok.svg)
exit
 ;;
'http://pclinuxos.mirror.wearetriple.com')
cp -rf "/usr/share/fastrepo/sources/apt/wearetriple" "/etc/apt/sources.list" 
cp -rf "/usr/share/fastrepo/sources/dnf/wearetriple.repo"  "/etc/repo.d/default.repo"
sleep 0.50 
$(yad --title="Fast Repo" \
--width=450 --height=100 --center --fixed \
--text=$"\nSelected repository: <span font_desc='Sans Bold Italic 10' foreground='#BE7F00'>http://pclinuxos.mirror.wearetriple.com</span>\n\nReload package manager to apply the repository changes.\n" \
--image="$ICON" \
--center \
--window-icon="$ICON" \
--button="Ok"!/usr/share/fastrepo/icons/ok.svg)
exit
 ;;
'http://distrib-coffee.ipsl.jussieu.fr')
cp -rf "/usr/share/fastrepo/sources/apt/coffee" "/etc/apt/sources.list" 
cp -rf "/usr/share/fastrepo/sources/dnf/coffee.repo"  "/etc/repo.d/default.repo"
sleep 0.50 
$(yad --title="Fast Repo" \
--width=450 --height=100 --center --fixed \
--text=$"\nSelected repository: <span font_desc='Sans Bold Italic 10' foreground='#BE7F00'>http://distrib-coffee.ipsl.jussieu.fr</span>\n\nReload package manager to apply the repository changes.\n" \
--image="$ICON" \
--center \
--window-icon="$ICON" \
--button="Ok"!/usr/share/fastrepo/icons/ok.svg)
exit
 ;;
'https://mirrors.cicku.me')
cp -rf "/usr/share/fastrepo/sources/apt/cicku" "/etc/apt/sources.list" 
cp -rf "/usr/share/fastrepo/sources/dnf/cicku.repo"  "/etc/repo.d/default.repo"
sleep 0.50 
$(yad --title="Fast Repo" \
--width=450 --height=100 --center --fixed \
--text=$"\nSelected repository: <span font_desc='Sans Bold Italic 10' foreground='#BE7F00'>https://mirrors.cicku.me</span>\n\nReload package manager to apply the repository changes.\n" \
--image="$ICON" \
--center \
--window-icon="$ICON" \
--button="Ok"!/usr/share/fastrepo/icons/ok.svg)
exit
 ;;
'https://mirror.freedif.org')
cp -rf "/usr/share/fastrepo/sources/apt/freedif" "/etc/apt/sources.list" 
cp -rf "/usr/share/fastrepo/sources/dnf/freedif.repo"  "/etc/repo.d/default.repo"
sleep 0.50 
$(yad --title="Fast Repo" \
--width=450 --height=100 --center --fixed \
--text=$"\nSelected repository: <span font_desc='Sans Bold Italic 10' foreground='#BE7F00'>https://mirror.freedif.org</span>\n\nReload package manager to apply the repository changes.\n" \
--image="$ICON" \
--center \
--window-icon="$ICON" \
--button="Ok"!/usr/share/fastrepo/icons/ok.svg)
exit
 ;;
'http://ftp.jaist.ac.jp')
cp -rf "/usr/share/fastrepo/sources/apt/jaist" "/etc/apt/sources.list" 
cp -rf "/usr/share/fastrepo/sources/dnf/jaist.repo"  "/etc/repo.d/default.repo"
sleep 0.50 
$(yad --title="Fast Repo" \
--width=450 --height=100 --center --fixed \
--text=$"\nSelected repository: <span font_desc='Sans Bold Italic 10' foreground='#BE7F00'>http://ftp.jaist.ac.jp</span>\n\nReload package manager to apply the repository changes.\n" \
--image="$ICON" \
--center \
--window-icon="$ICON" \
--button="Ok"!/usr/share/fastrepo/icons/ok.svg)
exit
 ;;
'https://mirror.webworld.ie')
cp -rf "/usr/share/fastrepo/sources/apt/webworld" "/etc/apt/sources.list" 
cp -rf "/usr/share/fastrepo/sources/dnf/webworld.repo"  "/etc/repo.d/default.repo"
sleep 0.50 
$(yad --title="Fast Repo" \
--width=450 --height=100 --center --fixed \
--text=$"\nSelected repository: <span font_desc='Sans Bold Italic 10' foreground='#BE7F00'>https://mirror.webworld.ie</span>\n\nReload package manager to apply the repository changes.\n" \
--image="$ICON" \
--center \
--window-icon="$ICON" \
--button="Ok"!/usr/share/fastrepo/icons/ok.svg)
exit
 ;;
'https://mirror.math.princeton.edu')
cp -rf "/usr/share/fastrepo/sources/apt/princeton" "/etc/apt/sources.list" 
cp -rf "/usr/share/fastrepo/sources/dnf/princeton.repo"  "/etc/repo.d/default.repo"
sleep 0.50 
$(yad --title="Fast Repo" \
--width=450 --height=100 --center --fixed \
--text=$"\nSelected repository: <span font_desc='Sans Bold Italic 10' foreground='#BE7F00'>https://mirror.math.princeton.edu</span>\n\nReload package manager to apply the repository changes.\n" \
--image="$ICON" \
--center \
--window-icon="$ICON" \
--button="Ok"!/usr/share/fastrepo/icons/ok.svg)
exit
 ;;
esac
fi



