Skip to content
Snippets Groups Projects
Commit fb723fad authored by Bob Mottram's avatar Bob Mottram
Browse files

Tidying

parent 47f5beb1
No related branches found
No related tags found
No related merge requests found
......@@ -38,6 +38,7 @@ NOT_ON_HOMEPAGE=1
SYNCTHING_ID=
SYNCTHING_CONFIG_PATH=/root/.config/syncthing
SYNCTHING_CONFIG_FILE=$SYNCTHING_CONFIG_PATH/config.xml
SYNCTHING_IDS_FILE=~/.syncthingids
SYNCTHING_RELAY_SERVER='https://relays.syncthing.net/endpoint'
SYNCTHING_RELEASES='https://api.github.com/repos/syncthing/syncthing/releases?per_page=30'
SYNCTHING_PORT=22000
......@@ -50,8 +51,6 @@ SYNCTHING_DESCRIPTION=$'File synchronization'
SYNCTHING_MOBILE_APP_URL='https://f-droid.org/packages/com.nutomic.syncthingandroid'
syncthing_variables=(SYNCTHING_ID
SYNCTHING_CONFIG_PATH
SYNCTHING_CONFIG_FILE
SYNCTHING_RELAY_SERVER
SYNCTHING_RELEASES
SYNCTHING_PORT
......@@ -89,13 +88,13 @@ function syncthing_create_ids_file {
fi
SYNCTHING_ID=$(cat ~/.syncthing-server-id)
if [ ! -f $SYNCTHING_CONFIG_FILE ]; then
if [ ! -f $SYNCTHING_IDS_FILE ]; then
{ echo $'# Your syncthing configuration file';
echo '#';
echo $"# The ${PROJECT_NAME} syncthing ID is: $SYNCTHING_ID";
echo '#';
echo '# Paste the IDs of your devices below';
echo '#'; } > $SYNCTHING_CONFIG_FILE
echo '#'; } > $SYNCTHING_IDS_FILE
fi
}
......@@ -104,7 +103,7 @@ function syncthing_manual_edit {
return
fi
syncthing_create_ids_file
editor $SYNCTHING_CONFIG_FILE
editor $SYNCTHING_IDS_FILE
# force an update of the configuration
touch ~/.syncthing-update
......@@ -164,7 +163,7 @@ function syncthing_add_id {
return
fi
if grep -q "$SYNCTHING_DEVICE_ID" $SYNCTHING_CONFIG_FILE; then
if grep -q "$SYNCTHING_DEVICE_ID" $SYNCTHING_IDS_FILE; then
dialog --title $"Add a Syncthing device ID" \
--backtitle $"Freedombone User Control Panel" \
--msgbox $"That ID has already been added" 6 50
......@@ -172,9 +171,9 @@ function syncthing_add_id {
fi
if [ ${#SYNCTHING_DESCRIPTION} -gt 0 ]; then
echo "# $SYNCTHING_DESCRIPTION" >> $SYNCTHING_CONFIG_FILE
echo "# $SYNCTHING_DESCRIPTION" >> $SYNCTHING_IDS_FILE
fi
echo "$SYNCTHING_DEVICE_ID" >> $SYNCTHING_CONFIG_FILE
echo "$SYNCTHING_DEVICE_ID" >> $SYNCTHING_IDS_FILE
# force an update of the configuration
touch ~/.syncthing-update
......@@ -218,14 +217,14 @@ function syncthing_remove_id {
return
fi
if ! grep -q "$SYNCTHING_DEVICE_ID" $SYNCTHING_CONFIG_FILE; then
if ! grep -q "$SYNCTHING_DEVICE_ID" $SYNCTHING_IDS_FILE; then
dialog --title $"Remove a Syncthing device ID" \
--backtitle $"Freedombone User Control Panel" \
--msgbox $"That ID wasn't registered anyway" 6 50
return
fi
sed -i "/$SYNCTHING_DEVICE_ID/d" $SYNCTHING_CONFIG_FILE
sed -i "/$SYNCTHING_DEVICE_ID/d" $SYNCTHING_IDS_FILE
# force an update of the configuration
touch ~/.syncthing-update
......@@ -236,7 +235,7 @@ function syncthing_remove_id {
}
function run_client_syncthing {
SYNCTHING_CONFIG_FILE=~/.syncthingids
SYNCTHING_IDS_FILE=~/.syncthingids
SYNCTHING_ID=$(cat ~/.syncthing-server-id)
W=(1 $"Show device ID for ${PROJECT_NAME}"
......@@ -452,6 +451,10 @@ function remove_syncthing {
remove_completion_param configure_firewall_for_syncthing
systemctl restart cron
if [ -f $SYNCTHING_IDS_FILE ]; then
rm $SYNCTHING_IDS_FILE
fi
for d in /home/*/ ; do
USERNAME=$(echo "$d" | awk -F '/' '{print $3}')
if [ -d "/home/$USERNAME/.config/syncthing" ]; then
......
......@@ -281,7 +281,7 @@ function user_devices_changed {
if [ -f "/home/$USERNAME/$SYNCTHING_UPDATE_FILE" ]; then
CHANGED=1
fi
x
if [ -f "/home/$USERNAME/$SYNCTHING_USER_IDS_FILE" ]; then
while read -r line || [[ -n "$line" ]]; do
if [[ $line != *"#"* && $line != *"*"* && $line != *'/'* && $line == *"-"* ]]; then
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment