Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 13 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,27 +1,34 @@
# Stop Nsurlsessiond on Mac OS
# Pause iCloud Sync on Mac OS

## General

### Description

This script will look on *nsurlsessiond* processus and will kill them by getting their **PID**
This script will look on *nsurlsessiond* and *cloudd* processus and will kill them by getting their **PID**, effectively pausing iCloud Sync on Mac OS.

### Installation

- Download the script
- Make sure you have the executive right (`chmod u+x ./StopNsurl.sh`)
- Make sure you have the right permissions to execute the command (`chmod u+x ./stop_icloud.sh`)

### Utilisation

Launch it with just `./StopNsurl.sh`.
Launch it with just `./stop_icloud.sh`.

**Verbose mode :** You can acces to the verbose mode by taping `./StopNsurl.sh -v`
**Verbose mode :** You can acces to the verbose mode by taping `./stop_icloud.sh -v`

I personally reccomend placing this script in a safe location and creating an alias in your shell profile like this: `alias [name of alias]='[the script's saved path]'`

Be sure to not include the brackets!

By setting an alias, you can run this script in the terminal by simply typing the name of this alias which'll probably make your life a lot easier!

### Stopping the script

The commum way to stop the script is to press `ctrl + c` on the terminal associated.
You can stop the script by pressing `ctrl + c` on the terminal where the script is running.


## Copyright

Created by **Lucas Tarasconi** the 07/04/2017
Modified by **Takami Marsh** 09/07/2024
58 changes: 31 additions & 27 deletions StopNsurl.sh → stop_icloud.sh
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
#! /bin/sh


## Description -----------

# Anti nsurlsessiond for macOS
# Looking for new 'nsurlsessiond' processus and killing it by getting his PID
# Anti cloudd and nsurlsessiond for macOS
# Looking for new 'cloudd' and 'nsurlsessiond' processes and killing them by getting their PIDs

# Made by Lucas Tarasconi
# 07/04/2017
# @Farnots
# Modified by Takami Marsh

## Spinner function -----------

Expand Down Expand Up @@ -41,12 +39,14 @@ PROCESS="${BLUE}[PROCESS]${NC}"
INFO="${GREEN}[INFO]${NC}"
WARNING="${ORANGE}[WARNING]${NC}"

## Welcome pannel -----------
## Welcome panel -----------


echo "+----------------------------------------+"
echo "| Starting annihilation of nsurlsessiond |"
echo "| Starting annihilation of cloudd and |"
echo "| nsurlsessiond |"
echo "| Made by Lucas Tarasconi |"
echo "| Modified by Takami Marsh |"
echo "+----------------------------------------+"


Expand All @@ -60,19 +60,20 @@ if [ $# -eq 1 ]; then
fi


## Removing the tempory file when exiting -----------
## Removing the temporary file when exiting -----------

quitting () {
echo "\n"
echo "${INFO} Removing tempory file"
rm ./.nsurlsessiond
echo "${INFO} Removing temporary files"
rm ./.cloudd ./.nsurlsessiond
echo "+----------------------------------------+"
echo "| Stoping annihilation of nsurlsessiond |"
echo "| Stopping annihilation of cloudd and |"
echo "| nsurlsessiond |"
echo "+----------------------------------------+"
exit 0
}

## Core of the script : kill all nsurlsession and show them -----------
## Core of the script : kill all cloudd and nsurlsessiond processes and show them -----------

killIt () {
n=$(expr $line)
Expand All @@ -85,25 +86,27 @@ speaking (){
killIt
current_time="`date +%H:%M:%S`"
printf "${PROCESS} ${current_time}"
printf " - killing nsurlsessiond number : $n"
printf " - killing process number: $n"
}

killNsurl () {
pgrep -x nsurlsessiond>./.nsurlsessiond
killProcesses () {
process_name=$1
temp_file="./.$process_name"
pgrep -x $process_name > $temp_file
while read line ; do
if [ $verbose -eq 1 ] ; then
speaking
else
killIt
fi
done <./.nsurlsessiond
done < $temp_file
if [ $verbose -eq 1 ] ; then
printf "\n"
printf "${INFO} Probing for new nsurlsessiond process"
printf "${INFO} Probing for new $process_name processes"
fi
}

## To avoid to use too many GPU just to kill processus -----------
## To avoid using too much CPU just to kill processes -----------

function waiting {
sleep 1
Expand All @@ -112,22 +115,23 @@ function waiting {
## While function -----------

trap "quitting" SIGTERM SIGINT
printf "${WARNING} Password could be asked once to have the right to kill 'nsurlsessiond' \n"
printf "${WARNING} Password could be asked once to have the right to kill 'cloudd' and 'nsurlsessiond' \n"
if [ $verbose -eq 1 ] ; then
printf "${INFO} Probing for new nsurlsessiond process "
printf "${INFO} Probing for new cloudd and nsurlsessiond processes "
else
printf "${INFO} Script is in progess ( '-v' to the verbose mode) : "
printf "${INFO} Script is in progress ( '-v' for verbose mode): "
fi
sleep 1
while [[ 1 ]]; do
pgrep -x nsurlsessiond>./.nsurlsessiond
pgrep -x cloudd > /dev/null
if [ $? -eq 0 ]; then
killProcesses cloudd
fi

pgrep -x nsurlsessiond > /dev/null
if [ $? -eq 0 ]; then
killNsurl
killProcesses nsurlsessiond
else
waiting & spinner
fi

done