-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup
executable file
·80 lines (79 loc) · 3.93 KB
/
setup
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#!/bin/bash
makeInstall () {
mkdir -p $HOME/.local/{bin,lib}
if ! test -d $HOME/.local/games; then
ln -s $HOME/.local/bin $HOME/.local/games
fi
mkdir -p $HOME/.local/share/portableapt
mkdir $HOME/.local/share/portableapt/{apt.conf.d,sources.list.d,lists,cache}
cp /etc/apt/apt.conf.d/* $HOME/.local/share/portableapt/apt.conf.d/
cp /etc/apt/sources.list.d/* $HOME/.local/share/portableapt/sources.list.d/
echo "AUTOUPDATE=ON" > $HOME/.local/share/portableapt/portableapt.conf
echo "Dir::Etc::Parts \"$HOME/.local/share/portableapt/apt.conf.d/\";Dir::Etc::SourceParts \"$HOME/.local/share/portableapt/sources.list.d/\";Dir::State::Lists \"$HOME/.local/share/portableapt/lists/\";Dir::Cache \"$HOME/.local/share/portableapt/cache/\";" > $HOME/.local/share/portableapt/apt.conf.d/papt.conf
wget --progress=dot -O $HOME/.local/bin/portableapt https://github.com/DocSystem/portableapt/raw/main/portableapt 2>&1 | grep "%" | sed -u -e "s,\.,,g" | awk '{print $2}' | sed -u -e "s,\%,,g" | whiptail --title "Portable APT Installer" --gauge "Téléchargement de Portable APT..." 8 78 0
chmod +x $HOME/.local/bin/portableapt
BashEnabled=OFF
ZshEnabled=OFF
KshEnabled=OFF
if test -f $HOME/.bashrc; then if grep -Fxq "export PATH=$HOME/.local/bin:\$PATH #portableapt" $HOME/.bashrc; then BashEnabled=ON; fi; fi
if test -f $HOME/.zshrc; then if grep -Fxq "export PATH=$HOME/.local/bin:\$PATH #portableapt" $HOME/.zshrc; then ZshEnabled=ON; fi; fi
if test -f $HOME/.kshrc; then if grep -Fxq "export PATH=$HOME/.local/bin:\$PATH #portableapt" $HOME/.kshrc; then KshEnabled=ON; fi; fi
SHELLS=$(whiptail --title "Portable APT Installer" --nocancel --checklist \
"Choisissez les Shells que vous souhaitez configurer pour Portable APT (Ajout au PATH)" 20 78 3 \
"bash" "Ajouter à .bashrc" $BashEnabled \
"zsh" "Ajouter à .zshrc" $ZshEnabled \
"ksh" "Ajouter à .kshrc" $KshEnabled 3>&1 1>&2 2>&3)
if [[ $SHELLS = *"bash"* ]]; then
if ! grep -Fxq "export PATH=$HOME/.local/bin:\$PATH #portableapt" $HOME/.bashrc; then
echo "export PATH=$HOME/.local/bin:\$PATH #portableapt" >> $HOME/.bashrc
fi
else
if test -f $HOME/.bashrc; then
if grep -Fxq "export PATH=$HOME/.local/bin:\$PATH #portableapt" $HOME/.bashrc; then
sed -i -e '/#portableapt/d' $HOME/.bashrc
fi
fi
fi
if [[ $SHELLS = *"zsh"* ]]; then
if ! grep -Fxq "export PATH=$HOME/.local/bin:\$PATH #portableapt" $HOME/.zshrc; then
echo "export PATH=$HOME/.local/bin:\$PATH #portableapt" >> $HOME/.zshrc
fi
else
if test -f $HOME/.zshrc; then
if grep -Fxq "export PATH=$HOME/.local/bin:\$PATH #portableapt" $HOME/.zshrc; then
sed -i -e '/#portableapt/d' $HOME/.zshrc
fi
fi
fi
if [[ $SHELLS = *"ksh"* ]]; then
if ! grep -Fxq "export PATH=$HOME/.local/bin:\$PATH #portableapt" $HOME/.kshrc; then
echo "export PATH=$HOME/.local/bin:\$PATH #portableapt" >> $HOME/.kshrc
fi
else
if test -f $HOME/.kshrc; then
if grep -Fxq "export PATH=$HOME/.local/bin:\$PATH #portableapt" $HOME/.kshrc; then
sed -i -e '/#portableapt/d' $HOME/.kshrc
fi
fi
fi
{
i=1
while read -r line; do
i=$(( $i + 1 ))
echo $i
done < <($HOME/.local/bin/portableapt update 2>/dev/null)
} | whiptail --title "Portable APT Installer" --gauge "Mise à jour des sources de Portable APT..." 8 78 0
whiptail --title "Portable APT Installer" --msgbox "Installation terminée !\nVeuillez redémarrer le terminal pour terminer l'installation de Portable APT" 8 82
}
if (whiptail --title "Portable APT Installer" --yesno "Souhaitez vous installer Portable APT ?" 8 78); then
if test -f $HOME/.local/bin/portableapt; then
if (whiptail --title "Portable APT Installer" --defaultno --yesno "Portable APT est déjà installé ! Voulez-vous vraiment continuer ?" 8 78); then
rm -f $HOME/.local/bin/portableapt
makeInstall
else
echo "Installation annulée ! "
fi
else
makeInstall
fi
fi