<commit_before>#!/bin/bash
#
# Script to remove headphone high level warning and word prediction
# It also changes sd card mount rights (umask and fmask 0002) 
#

if [ "root" != "$(whoami)" ]; then
	echo "You must run this script as root!"
	exit 1
fi


unset MOUNT_SD
MOUNT_SD="/usr/sbin/mount-sd.sh"



###
# Remove volume warning
###

# create backup
vol_warning_path="/etc/pulse/mainvolume-listening-time-notifier.conf"
cp "$vol_warning_path" "${vol_warning_path}.bak"
if [ "0" == "$?" ]; then
	echo "Backup created for $vol_warning_path"
else
	echo "Cannot create backup for $vol_warning_path"
	exit 2
fi

# change setting
sed -i s/mode-list\ =\ lineout,hs/mode-list\ =\/ "$vol_warning_path"
if [ "0" == "$?"  ]; then
	echo "Changes saved for $vol_warning_path"
else
	echo "Cannot provide changes for $vol_warning_path"
	exit 3
fi


###
# Remove word prediction
###

# backup 
word_prediction="/usr/share/maliit/plugins/com/jolla/layouts/layouts.conf"
cp "$word_prediction" "${word_prediction}.bak"
if [ "0" == "$?" ]; then
  echo "Backup created for $word_prediction"
else
  echo "Cannot create backup for $word_prediction"
  exit 4
fi

# find and replace
sed -i s/handler=Xt9InputHandler.qml/#\ handler=Xt9InputHandler.qml/g "$word_prediction"
if [ "0" == "$?"  ]; then
  echo "Changes saved for $word_prediction"
else
  echo "Cannot provide changes for $word_prediction"
  exit 5
fi

# keyboard service restart
systemctl --user restart maliit-server.service
if [ "0" == "$?"  ]; then
  echo "Keyboard service restarted"
else
  echo "Cannot restart keyboard service"
  exit 6
fi


###
# Change mount options (mask for files and directories for sd card)
###

#backup 
cp "$MOUNT_SD" "${MOUNT_SD}.bak"
if [ "0" == "$?" ]; then
  echo "Backup created for $MOUNT_SD"
else
  echo "Cannot create backup for $word_prediction"
  exit 7
fi

# replace
sed -i s:'DEVNAME=$2':'DEVNAME=$2\n\n# trying to mount bind owncloud directory (on sd) to dir on sd\nunset MASK\nMASK="fmask=0002,dmask=0002"':g
if [ "0" != "$?" ]; then
  echo "Cannot add variables in $MOUNT_SD with sed"
  exit 8
fi

sed -i s:'mount ${DEVNAME} $MNT/${UUID} -o uid=$DEF_UID,gid=$DEF_GID,$MOUNT_OPTS,utf8,flush,discard || /bin/rmdir $MNT/${UUID}':'mount ${DEVNAME} $MNT/${UUID} -o uid=$DEF_UID,gid=$DEF_GID,$MOUNT_OPTS,utf8,flush,discard,$MASK || /bin/rmdir $MNT/${UUID}\n      mount --bind  $MNT/${UUID}/owncloud/ /home/nemo/android_storage/owncloud':g
if [ "0" != "$?" ]; then
	echo "Cannot replace mount options in $MOUNT_SD with sed"
	exit 9
else
	echo "Mount options (fmask and dmask) for sd card added"
fi

echo "Restarting machine"
reboot
<commit_msg>Fixed sed command (path to script added)<commit_after>#!/bin/bash
#
# Script to remove headphone high level warning and word prediction
# It also changes sd card mount rights (umask and fmask 0002) 
#

if [ "root" != "$(whoami)" ]; then
	echo "You must run this script as root!"
	exit 1
fi


unset MOUNT_SD
MOUNT_SD="/usr/sbin/mount-sd.sh"



###
# Remove volume warning
###

# create backup
vol_warning_path="/etc/pulse/mainvolume-listening-time-notifier.conf"
cp "$vol_warning_path" "${vol_warning_path}.bak"
if [ "0" == "$?" ]; then
	echo "Backup created for $vol_warning_path"
else
	echo "Cannot create backup for $vol_warning_path"
	exit 2
fi

# change setting
sed -i s/mode-list\ =\ lineout,hs/mode-list\ =\/ "$vol_warning_path"
if [ "0" == "$?"  ]; then
	echo "Changes saved for $vol_warning_path"
else
	echo "Cannot provide changes for $vol_warning_path"
	exit 3
fi


###
# Remove word prediction
###

# backup 
word_prediction="/usr/share/maliit/plugins/com/jolla/layouts/layouts.conf"
cp "$word_prediction" "${word_prediction}.bak"
if [ "0" == "$?" ]; then
  echo "Backup created for $word_prediction"
else
  echo "Cannot create backup for $word_prediction"
  exit 4
fi

# find and replace
sed -i s/handler=Xt9InputHandler.qml/#\ handler=Xt9InputHandler.qml/g "$word_prediction"
if [ "0" == "$?"  ]; then
  echo "Changes saved for $word_prediction"
else
  echo "Cannot provide changes for $word_prediction"
  exit 5
fi

# keyboard service restart
systemctl --user restart maliit-server.service
if [ "0" == "$?"  ]; then
  echo "Keyboard service restarted"
else
  echo "Cannot restart keyboard service"
  exit 6
fi


###
# Change mount options (mask for files and directories for sd card)
###

#backup 
cp "$MOUNT_SD" "${MOUNT_SD}.bak"
if [ "0" == "$?" ]; then
  echo "Backup created for $MOUNT_SD"
else
  echo "Cannot create backup for $word_prediction"
  exit 7
fi

# replace
sed -i s:'DEVNAME=$2':'DEVNAME=$2\n\n# trying to mount bind owncloud directory (on sd) to dir on sd\nunset MASK\nMASK="fmask=0002,dmask=0002"':g "$MOUNT_SD"
if [ "0" != "$?" ]; then
  echo "Cannot add variables in $MOUNT_SD with sed"
  exit 8
fi

sed -i s:'mount ${DEVNAME} $MNT/${UUID} -o uid=$DEF_UID,gid=$DEF_GID,$MOUNT_OPTS,utf8,flush,discard || /bin/rmdir $MNT/${UUID}':'mount ${DEVNAME} $MNT/${UUID} -o uid=$DEF_UID,gid=$DEF_GID,$MOUNT_OPTS,utf8,flush,discard,$MASK || /bin/rmdir $MNT/${UUID}\n      mount --bind  $MNT/${UUID}/owncloud/ /home/nemo/android_storage/owncloud':g "$MOUNT_SD"
if [ "0" != "$?" ]; then
	echo "Cannot replace mount options in $MOUNT_SD with sed"
	exit 9
else
	echo "Mount options (fmask and dmask) for sd card added"
fi

echo "Restarting machine"
reboot

{'fraction_non_alphanumeric': 0.14768649669499528, 'fraction_numerical': 0.013220018885741265, 'mean_word_length': 4.4541709577754895, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2314410', 'n_tokens_mistral': 1963, 'n_tokens_neox': 1923, 'n_words': 584}