Skip to content
This repository has been archived by the owner on May 1, 2022. It is now read-only.

Commit

Permalink
Merge branch 'main' of https://github.com/Itai-Nelken/Pi-Assistant in…
Browse files Browse the repository at this point in the history
…to main
  • Loading branch information
Itai-Nelken committed Feb 5, 2021
2 parents e50613f + f388842 commit 255aa5e
Show file tree
Hide file tree
Showing 3 changed files with 132 additions and 87 deletions.
58 changes: 47 additions & 11 deletions apps/etcher.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,24 @@ function error {
echo -e "\e[91m$1\e[39m"
}

function download_latest_release_armhf() {
echo "Downloading latest armhf release..."
curl -s https://api.github.com/repos/$1/releases/latest \
| grep "browser_download_url.*armv7l.deb" \
| cut -d : -f 2,3 \
| tr -d \" \
| wget -qi -
}

function download_latest_release_arm64() {
echo "Downloading latest arm64 release..."
curl -s https://api.github.com/repos/$1/releases/latest \
| grep "browser_download_url.*armv64.deb" \
| cut -d : -f 2,3 \
| tr -d \" \
| wget -qi -
}

#variables
DIRECTORY="$HOME/Pi-Assistant"
APPS="$HOME/Pi-Assistant/apps"
Expand All @@ -20,26 +38,44 @@ do
"install")

sudo apt update || error "Failed to update repos (not critical)."
if $(uname -m | grep '64'); then

wget https://github.com/Itai-Nelken/Etcher-arm-32-64/releases/download/realease/balena-etcher-electron_1.5.110+1f8f7ad7_arm64.deb -O ~/etcher64.deb || error "Failed to download!"

sudo apt install -y --fix-broken ~/etcher64.deb || error "failed to install deb file!"
rm -f ~/etcher64.deb
#determine if host system is 64 bit arm64 or 32 bit armhf
if [ ! -z "$(file "$(readlink -f "/sbin/init")" | grep 64)" ];then
echo "Installing arm64 etcher..."
cd $HOME || error "Failed to change to home directory (not super critical)"
download_latest_release_arm64 Itai-Nelken/Etcher-arm-32-64 || error "Failed to Download etcher!"; read -p "press enter to exit"; exit 1
sudo apt -f -y install ./balena-etcher-electron*arm64.deb || error "Failed to install etcher deb!"; read -p "press enter to exit"; exit 1
rm -f balena-etcher-electron*arm64.deb || error "Failed to delete etcher deb (not critical)"
elif [ ! -z "$(file "$(readlink -f "/sbin/init")" | grep 32)" ];then
echo "Installing armhf etcher..."
cd $HOME || error "Failed to change to home directory (not super critical)"
download_latest_release_armhf Itai-Nelken/Etcher-arm-32-64 || error "Failed to Download etcher!"; read -p "press enter to exit"; exit 1
sudo apt -f -y ./install balena-etcher-electron*armv7l.deb || error "Failed to install etcher deb!"; read -p "press enter to exit"; exit 1
rm -f balena-etcher-electron*armv7l.deb || error "Failed to delete etcher deb (not critical)"
else
wget https://github.com/Itai-Nelken/Etcher-arm-32-64/releases/download/realease/balena-etcher-electron_1.5.110+1f8f7ad7_armv7l.deb -O ~/etcher32.deb || error "Failed to download!"

sudo apt install -y --fix-broken ~/etcher32.deb || error "failed to install deb file!"
rm -f ~/etcher32.deb

error "Failed to detect OS CPU architecture! Something is very wrong."
fi

#if $(uname -m | grep '64'); then
#
# wget https://github.com/Itai-Nelken/Etcher-arm-32-64/releases/download/realease/balena-etcher-electron_1.5.110+1f8f7ad7_arm64.deb -O ~/etcher64.deb || error "Failed to download!"
#
# sudo apt install -y --fix-broken ~/etcher64.deb || error "failed to install deb file!"
# rm -f ~/etcher64.deb
#else
# wget https://github.com/Itai-Nelken/Etcher-arm-32-64/releases/download/realease/balena-etcher-electron_1.5.110+1f8f7ad7_armv7l.deb -O ~/etcher32.deb || error "Failed to download!"
#
# sudo apt install -y --fix-broken ~/etcher32.deb || error "failed to install deb file!"
# rm -f ~/etcher32.deb
#
#fi

break
;;

"compile")

wget -qO- https://raw.githubusercontent.com/Itai-Nelken/Etcher-arm-32-64/main/compile-etcher_v1.5.113.sh | bash || error "Failed to download and run compile sctipt!"
wget -qO- https://raw.githubusercontent.com/Itai-Nelken/Etcher-arm-32-64/main/compile-etcher_v1.5.116.sh | bash || error "Failed to download and run compile sctipt!"
read -p "do you want to install etcher from the deb you just compiled (y/n)?" choice
case "$choice" in
y|Y ) echo "installing etcher..." && cd $HOME/Downloads/etcher/dist && sudo apt install -y --fix-missing balena-etcher-electron*.deb;;
Expand Down
8 changes: 4 additions & 4 deletions main.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,6 @@ fi
DIRECTORY="$HOME/Pi-Assistant"
APPS="$HOME/Pi-Assistant/apps"

#print a "loading screen"
echo "$(tput setaf 2)$(tput bold)LOADING...$(tput sgr 0)"

#flags
if [[ $1 = "--version" ]]; then
echo -e "$(tput bold)$(tput setaf 4)Pi-Assistant\nv1.2.1\nby Itai Nelken$(tput sgr 0)"
Expand Down Expand Up @@ -63,8 +60,11 @@ elif [[ $1 = "--no-update" ]]; then
UPDATE=0
fi

#print a "loading screen"
echo "$(tput setaf 2)$(tput bold)LOADING...$(tput sgr 0)"

#check for internet connection (disable with -ni flag)
if [[ "$NOINTERNETCHECK" == 1 ]]; then
if [[ "$NOINTERNETCHECK" != 1 ]]; then
PINGOUTPUT=$(ping -c 1 8.8.8.8 >/dev/null && echo '...')
if [ ! "$PINGOUTPUT" = '...' ]; then
UPDATE=0
Expand Down
153 changes: 81 additions & 72 deletions updater.sh
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
#!/bin/bash

function error {
function error() {
echo -e "\e[91m$1\e[39m"
}

DIRECTORY="$HOME/Pi-Assistant"
APPS="$HOME/Pi-Assistant/apps"

#update function
function update {
function update() {
echo "Checking for updates..."
cd $DIRECTORY
localhash="$(git rev-parse HEAD)"
Expand All @@ -18,20 +18,24 @@ function update {
git clean -fd
git reset --hard
git pull https://github.com/Itai-Nelken/Pi-Assistant.git HEAD || error 'Unable to update, please check your internet connection'
make-all-executable
refresh-shortcuts
else
echo "Up to date."
fi
}

#update function with no extra output
function update-no-output {
function update-no-output() {
cd $DIRECTORY
localhash="$(git rev-parse HEAD)"
latesthash="$(git ls-remote https://github.com/Itai-Nelken/Pi-Assistant HEAD | awk '{print $1}')"
if [ "$localhash" != "$latesthash" ] && [ ! -z "$latesthash" ] && [ ! -z "$localhash" ];then
git clean -fd
git reset --hard
git pull https://github.com/Itai-Nelken/Pi-Assistant.git HEAD || error 'Unable to update, please check your internet connection'
make-all-executable
refresh-shortcuts
else
clear
#print a "loading screen"
Expand All @@ -40,79 +44,84 @@ function update-no-output {

}

if [[ $1 = "--no-output" ]]; then
update-no-output
else
update
fi
function make-all-executable() {
sudo chmod +x main.sh
sudo chmod +x passwd.sh
sudo chmod +x systools.sh
sudo chmod +x other.sh
sudo chmod +x install.sh
sudo chmod +x update.sh
sudo chmod +x updater.sh
sudo chmod +x uninstall.sh
sudo chmod +x sys-info.sh
sudo chmod +x apps/appinstaller.sh
sudo chmod +x apps/gparted.sh
sudo chmod +x apps/chromium.sh
sudo chmod +x apps/firefox.sh
sudo chmod +x apps/blender.sh
sudo chmod +x apps/audacity.sh
sudo chmod +x apps/inkscape.sh
sudo chmod +x apps/snap.sh
sudo chmod +x apps/SSR.sh
sudo chmod +x apps/kdenlive.sh
sudo chmod +x apps/gsysmon.sh
sudo chmod +x apps/flatpak.sh
sudo chmod +x apps/etcher.sh
sudo chmod +x apps/zoom.sh
sudo chmod +x apps/box86.sh
}

function refresh-shortcuts() {
rm ~/.local/share/applications/piassist.desktop
rm ~/Desktop/piassist.desktop

sudo chmod +x main.sh
sudo chmod +x passwd.sh
sudo chmod +x systools.sh
sudo chmod +x other.sh
sudo chmod +x install.sh
sudo chmod +x update.sh
sudo chmod +x updater.sh
sudo chmod +x uninstall.sh
sudo chmod +x sys-info.sh
sudo chmod +x apps/appinstaller.sh
sudo chmod +x apps/gparted.sh
sudo chmod +x apps/chromium.sh
sudo chmod +x apps/firefox.sh
sudo chmod +x apps/blender.sh
sudo chmod +x apps/audacity.sh
sudo chmod +x apps/inkscape.sh
sudo chmod +x apps/snap.sh
sudo chmod +x apps/SSR.sh
sudo chmod +x apps/kdenlive.sh
sudo chmod +x apps/gsysmon.sh
sudo chmod +x apps/flatpak.sh
sudo chmod +x apps/etcher.sh
sudo chmod +x apps/zoom.sh
sudo chmod +x apps/box86.sh
#update menu shortcut
echo "[Desktop Entry]
StartupNotify=true
Terminal=true
Type=Application
Name=Pi-Assistant
Exec="$HOME/Pi-Assistant/main.sh"
Icon="$HOME/Pi-Assistant/icons/64x64/logo-64.png"
Categories=Utility;
Comment="Pi-Assistant v1.2.1"" > ~/.local/share/applications/piassist.desktop
cp ~/.local/share/applications/piassist.desktop ~/Desktop/piassist.desktop
sudo chmod +x ~/Desktop/piassist.desktop

sudo rm /usr/local/bin/piassist
#update startup from terminal using 'piassist'
echo '#!/bin/bash
cd ~/Pi-Assistant
#flags
if [[ $1 = "--version" ]]; then
echo -e "$(tput bold)$(tput setaf 4)Pi-Assistant\nv1.2.1\nby Itai Nelken$(tput sgr 0)"
exit
elif [[ $1 = "--secret" ]]; then
xdg-open ~/Pi-Assistant/icons/ascii-art.html
sleep 10
clear
read -p "press [ENTER] to exit"
exit
elif [[ $1 = "--no-internet" ]]; then
./main.sh --no-internet
elif [[ $1 = "--help" ]]; then
./main.sh --help
elif [[ $1 = "--no-update" ]]; then
./main.sh --no-update
else
clear && $HOME/Pi-Assistant/main.sh
fi' > ~/Downloads/piassist
sudo mv ~/Downloads/piassist /usr/local/bin/
sudo chmod +x /usr/local/bin/piassist
}

rm ~/.local/share/applications/piassist.desktop
rm ~/Desktop/piassist.desktop

#update menu shortcut
echo "[Desktop Entry]
StartupNotify=true
Terminal=true
Type=Application
Name=Pi-Assistant
Exec="$HOME/Pi-Assistant/main.sh"
Icon="$HOME/Pi-Assistant/icons/64x64/logo-64.png"
Categories=Utility;
Comment="Pi-Assistant v1.2.1"" > ~/.local/share/applications/piassist.desktop
cp ~/.local/share/applications/piassist.desktop ~/Desktop/piassist.desktop
sudo chmod +x ~/Desktop/piassist.desktop

sudo rm /usr/local/bin/piassist
#update startup from terminal using 'piassist'
echo '#!/bin/bash
cd ~/Pi-Assistant
#flags
if [[ $1 = "--version" ]]; then
clear
echo -e "$(tput bold)$(tput setaf 4)Pi-Assistant\nv1.2.1\nby Itai Nelken$(tput sgr 0)"
read -p "press [ENTER] to exit..."
exit
elif [[ $1 = "--secret" ]]; then
xdg-open ~/Pi-Assistant/icons/ascii-art.html
sleep 10
clear
read -p "press [ENTER] to exit"
exit
elif [[ $1 = "--no-internet" ]]; then
./main.sh --no-internet
elif [[ $1 = "--help" ]]; then
./main.sh --help
elif [[ $1 = "--no-update" ]]; then
./main.sh --no-update
if [[ "$1" == "--no-output" ]]; then
update-no-output
else
clear && $HOME/Pi-Assistant/main.sh
fi' > ~/Downloads/piassist
sudo mv ~/Downloads/piassist /usr/local/bin/
sudo chmod +x /usr/local/bin/piassist
update
fi


#echo "$(tput setaf 3)finished...$(tput sgr 0)"

0 comments on commit 255aa5e

Please sign in to comment.