sudoless update

This commit is contained in:
Mentor
2022-09-19 20:02:25 +02:00
parent d12fb03daf
commit e16b2de3d2
4 changed files with 64 additions and 50 deletions

View File

@@ -1,14 +1,15 @@
#!/bin/bash
platypus=$1
# User welcome message
if [ -z "$platypus" ]; then
echo -e "\n####################################################################"
echo '# 👋 Welcome, this is the setup script for the battery CLI tool.'
echo -e "# Note: this script will ask for your password once or multiple times."
echo -e "####################################################################\n\n"
fi
echo -e "\n####################################################################"
echo '# 👋 Welcome, this is the setup script for the battery CLI tool.'
echo -e "# Note: this script will ask for your password once or multiple times."
echo -e "####################################################################\n\n"
# Set environment variables
tempfolder=~/.battery-tmp
binfolder=/usr/local/bin
mkdir -p $tempfolder
# Ask for sudo once, in most systems this will cache the permissions for a bit
sudo echo "🔋 Starting battery installation"
@@ -16,12 +17,9 @@ sudo echo "🔋 Starting battery installation"
echo -e "\n[ 1/9 ] Superuser permissions acquired."
# Get smc source and build it
tempfolder=~/.battery-tmp
binfolder=/usr/local/bin
mkdir -p $tempfolder
smcfolder="$tempfolder/smc"
echo "[ 2/9 ] Cloning fan control version of smc"
rm -rf $smcfolder
git clone --depth 1 https://github.com/hholtmann/smcFanControl.git $smcfolder &> /dev/null
cd $smcfolder/smc-command
echo "[ 3/9 ] Building smc from source"
@@ -39,6 +37,7 @@ echo "[ 5/9 ] Cloning battery repository"
git clone --depth 1 https://github.com/actuallymentor/battery.git $bateryfolder &> /dev/null
echo "[ 6/9 ] Writing script to $binfolder/battery"
sudo cp $bateryfolder/battery.sh $binfolder/battery
sudo chown $USER $binfolder/battery
sudo chmod 755 $binfolder/battery
sudo chmod u+x $binfolder/battery
@@ -51,8 +50,4 @@ echo "[ 8/9 ] Removing temp folder $tempfolder"
rm -rf $tempfolder
echo "[ 9/9 ] Removed temporary build files"
if [ -z "$platypus" ]; then
echo -e "\n🎉 Battery tool installed. Type \"battery\" for instructions.\n"
fi
echo -e "\n🎉 Battery tool installed. Type \"battery help\" for instructions.\n"