mirror of
https://github.com/actuallymentor/battery.git
synced 2026-02-03 14:03:24 +00:00
🐛 install xcode-select if git is not yet installed
This commit is contained in:
30
setup.sh
30
setup.sh
@@ -17,32 +17,44 @@ configfolder=/Users/$calling_user/.battery
|
||||
pidfile=$configfolder/battery.pid
|
||||
logfile=$configfolder/battery.log
|
||||
|
||||
|
||||
# Ask for sudo once, in most systems this will cache the permissions for a bit
|
||||
sudo echo "🔋 Starting battery installation"
|
||||
|
||||
echo -e "\n[ 1/9 ] Superuser permissions acquired."
|
||||
# Check if git is installed, and if not, install it
|
||||
if ! which git &> /dev/null; then
|
||||
echo -e "\n[ 1/10 ] Xcode build tools are not installed, please accept the xcode dialog"
|
||||
xcode-select --install
|
||||
if ! which git; then
|
||||
echo "Build tools not installed, please run this script again"
|
||||
fi
|
||||
else
|
||||
echo -e "\n[ 1/10 ] Xcode build tools are installed, continuing"
|
||||
fi
|
||||
|
||||
echo -e "[ 2/10 ] Superuser permissions acquired."
|
||||
|
||||
# Get smc source and build it
|
||||
smcfolder="$tempfolder/smc"
|
||||
echo "[ 2/9 ] Cloning fan control version of smc"
|
||||
echo "[ 3/10 ] 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"
|
||||
echo "[ 4/10 ] Building smc from source"
|
||||
make &> /dev/null
|
||||
|
||||
# Move built file to bin folder
|
||||
echo "[ 4/9 ] Move smc to executable folder"
|
||||
echo "[ 5/10 ] Move smc to executable folder"
|
||||
sudo mkdir -p $binfolder
|
||||
sudo mv $smcfolder/smc-command/smc $binfolder
|
||||
sudo chmod u+x $binfolder/smc
|
||||
|
||||
# Write battery function as executable
|
||||
batteryfolder="$tempfolder/battery"
|
||||
echo "[ 5/9 ] Cloning battery repository"
|
||||
echo "[ 6/10 ] Cloning battery repository"
|
||||
git clone --depth 1 https://github.com/actuallymentor/battery.git $batteryfolder &> /dev/null
|
||||
|
||||
echo "[ 6/9 ] Writing script to $binfolder/battery for user $calling_user"
|
||||
echo "[ 7/10 ] Writing script to $binfolder/battery for user $calling_user"
|
||||
sudo cp $batteryfolder/battery.sh $binfolder/battery
|
||||
|
||||
# Set permissions for battery executables
|
||||
@@ -65,12 +77,12 @@ sudo chmod 755 $pidfile
|
||||
sudo chown $calling_user $binfolder/battery
|
||||
|
||||
sudo bash $batteryfolder/battery.sh visudo
|
||||
echo "[ 7/9 ] Set up visudo declarations"
|
||||
echo "[ 8/10 ] Set up visudo declarations"
|
||||
|
||||
# Remove tempfiles
|
||||
cd ../..
|
||||
echo "[ 8/9 ] Removing temp folder $tempfolder"
|
||||
echo "[ 9/10 ] Removing temp folder $tempfolder"
|
||||
rm -rf $tempfolder
|
||||
echo "[ 9/9 ] Removed temporary build files"
|
||||
echo "[ 10/10 ] Removed temporary build files"
|
||||
|
||||
echo -e "\n🎉 Battery tool installed. Type \"battery help\" for instructions.\n"
|
||||
|
||||
Reference in New Issue
Block a user