Search This Blog

2025/02/27

SysV service '/etc/init.d/speech-dispatcher' lacks a native systemd unit file

Problem Statement:
 
Debian 12 boot error
journalctl --pager

Output(Only Part Concerned):
Feb 27 10:13:03 debian systemd-sysv-generator[7216]: SysV service '/etc/init.d/speech-dispatcher'
lacks a native systemd unit file, automatically generating a unit file for compatibility.
Feb 27 10:13:03 debian systemd-sysv-generator[7216]: Please update package to include a native
systemd unit file.

Probable Solution:

systemctl list-unit-files | grep enabled will list all enabled ones.

systemctl | grep running

Command
systemctl list-unit-files --state=enabled
Output:
UNIT FILE STATE PRESET
speech-dispatcher.service generated -
speech-dispatcherd.service disabled enabled

Start the service & verify the status
Run(Shell Terminal Commands):
sudo systemctl status speech-dispatcher.service
sudo systemctl enable speech-dispatcher.service
sudo systemctl start speech-dispatcher.service
sudo systemctl status speech-dispatcher.service



debian systemd-sysv-generator[7216]: SysV service '/etc/init.d/gdomap' lacks a native systemd unit file

Problem Statement:
Debian 12 boot error saying debian systemd-sysv-generator[7216]: SysV
service '/etc/init.d/gdomap' lacks a native systemd unit file.

Verify the error:
journalctl --pager

Output(Only Part Concerned):
Feb 27 10:13:03 debian systemd-sysv-generator[7216]: SysV service '/etc/init.d/gdomap' lacks
a native systemd unit file, automatically generating a unit file for compatibility.
Feb 27 10:13:03 debian systemd-sysv-generator[7216]: Please update package to include a
native systemd unit file.
Feb 27 10:13:03 debian systemd-sysv-generator[7216]: ! This compatibility logic is deprecated,
expect removal soon. !

Probable Solution:
First check the shell script gdomap exist at desired location.In our case '/etc/init.d'

Run(Shell Terminal Commands):
cd /etc/init.d
ls | grep gdomap

If you find gdomap file & its not empty then only systemctl service from init.d may
have failed to start somehow.

Lets try to start that service manually.
Start the gdomap.service & verify the status

sudo systemctl status gdomap.service
sudo systemctl enable gdomap.service
sudo systemctl start gdomap.service
sudo systemctl status gdomap.service

Use journalctl to View Your System's Logs

View journalctl without Paging

To send your logs to standard output and avoid paging them, use 
        the --no-pager option:

journalctl --no-pager

It's not recommended that you do this without first filtering down 
        the number of logs shown.

journalctl -u service-name.service︙

Show Logs within a Time Range

Use the --since option to show logs after a specified date and 
            time:

journalctl --since "2018-08-30 14:10:10"

Use the --until option to show logs up to a specified date and time:

journalctl --until "2018-09-02 12:05:50"

Combine these to show logs between the two times:

journalctl --since "2018-08-30 14:10:10" --until "2018-09-02 12:05:50"


Content is shamelessly copied from:
https://unix.stackexchange.com/questions/225401
/how-to-see-full-log-from-systemctl-status-service

from the answer by: https://unix.stackexchange.com/users/119298
/jeff-schaller 
 
    for purpose of documenting future reference assuming the original 
    content may be removed or altered.

References:
https://www.linode.com/docs/guides/how-to-use-journalctl

2025/02/26

Bash script to collect .mp3 files from album folder to Music folder directly

Suppose you have two folders /home/sangram/Music & /home/sangram/Music/Other,
In Music Folder you only want to keep mp3 files directly.The Other folder 
contain multiple folders each containing mp3 files for different Song Album.
 
Here instead of directly copying mp3 to 'Music' folder i created another folder
in 'Music' folder to collect all such files named 'AllSongs'
 
Then following script will copy all mp3 files from Album folders to mp3.It does
not implement nested folder scenario.Code is Bash Script that can be run as
 
Assume code file name is OrganizeMusicFiles.sh then you need to base folder of
it to make it executable run
chmod +x OrganizeMusicFiles.sh

Then run script as follows  
./OrganizeMusicFiles.sh
 
 
Code: 
 
/bin/bash 
search_dir=/home/sangram/Music/Other
dest_dir=/home/sangram/Music/AllSongs/
echo "Search Directory: $search_dir"
echo "Destination Directory: $dest_dir"
echo "--------------------------------"

touch CopyLog.psv
echo "source|destinaion|time" > CopyLog.psv;

counter=0
break_flag=0
for entry in "$search_dir"/*; do
echo "--------------Folder:$entry------------------"
for inner_entry in "$entry"/*; do
echo "File under consideration is: $inner_entry"

#get file extension
filename=$(basename -- "$inner_entry")
extension="${filename##*.}"
echo "File Extension: $extension"
desired_extensions=("mp3")

if [[ ${desired_extensions[@]} =~ $extension ]]
then
echo "File $inner_entry is mp3"
else
echo "File $inner_entry is not mp3"
continue
fi

echo "Coping File:'$inner_entry' To '$dest_dir'"
echo "cp '$inner_entry' '$dest_dir'"

#logging the copy operation
current_date_time="`date +%Y%m%d%H%M%S`";
echo "'$inner_entry'|'$dest_dir'|'$current_date_time'" >> CopyLog.psv;
echo "\n" >> CopyLog.psv;

cp "$inner_entry" '$dest_dir'
counter=$((counter+1))

#coping only 10 files
if [ $counter -eq 10 ]
then
$break_flag=1
break
fi

echo '--------------------------------'


done
#if inner loop is broken then break outer loop also broken
if [ $break_flag -eq 1 ]
then
break
fi
echo "Total Files Copied: $counter"
break
done
 
I think the code might useful for someone which trying to something similar 
for sake of fun.
 
Happy Coding !
 
 

2025/02/25

How to create bootable USB stick from iso file in Debian GNU/Linux 12 ?

Download ISO file from your preferred distro if that burn on CD/DVD then system can boot
from this CD/DVD.

   I am downloading latest version of Ubuntu from Office Website.

DOWNLOAD URL:https://mirrors.utkarsh2102.org/ubuntu-releases/24.10
             /ubuntu-24.10-desktop-amd64.iso
   	
I found out that downloading from torrent is better else you need to use Download Manager 
Application to avoid interruption in network connection.
   
Path to downloaded ISO
  Find path to downloaded ISO.In my case the path is
	
       	/home/sangram/Downloads/ubuntu-24.10-desktop-amd64.iso
   
Then Find path to your Flash Drive.
	root@debian:/home/sangram/Downloads# blkid
	/dev/sdb4: UUID="4bec5b9b-0399-4625-888e-1f3c7879a2d2" BLOCK_SIZE="4096" 
                        TYPE="ext4" PARTUUID="709020f5-3615-48ae-945e-7aaf90e1c224"
	/dev/sdb2: LABEL="Windows10Extra" BLOCK_SIZE="512" UUID="8E80C8B780C8A6D5" 
                        TYPE="ntfs" PARTUUID="2e556718-1bca-45e6-a8e1-da6176028372"
	/dev/sdb3: UUID="998967c0-01bb-435c-be51-5111ac2f42dd" 
                        TYPE="swap" PARTUUID="7f3e46bb-d429-4255-85b6-d574874b0441"
	/dev/sdb1: LABEL="UbuntuExtra" UUID="32d124b4-f63e-4db8-9862-2bd1ccce96d9" 
                        BLOCK_SIZE="4096" TYPE="ext4" PARTUUID="022273ff-1744-4ddf-918b-454356e51fae"
	/dev/sr0: BLOCK_SIZE="2048" UUID="2002-12-25-13-26-43-00" 
                        LABEL="021225_1321" TYPE="iso9660"
	/dev/sda4: UUID="f2138513-5e98-4fc3-a41d-a43a68a9239b" 
                        BLOCK_SIZE="4096" TYPE="xfs" PARTUUID="869e87f7-04"
	/dev/sda2: BLOCK_SIZE="512" UUID="FA0A69290A68E3DB" TYPE="ntfs" 
                        PARTUUID="869e87f7-02"
	/dev/sda3: BLOCK_SIZE="512" UUID="1EAEDC1BAEDBE973" TYPE="ntfs" 
                        PARTUUID="869e87f7-03"
	/dev/sda1: LABEL="System Reserved" BLOCK_SIZE="512" UUID="201667091666DF72" 
                        TYPE="ntfs" PARTUUID="869e87f7-01"
	/dev/sdc: UUID="C471-F788" BLOCK_SIZE="512" TYPE="vfat"

Here /dev/sdc is my Flash USB Drive on which I want to install Bootable Ubuntu.

Command Format:
	sudo dd if=[path_to_iso] of=[path_to_usb]

Actual command in our case will look like

	sudo dd  bs=4M if=/home/sangram/Downloads/ubuntu-24.10-desktop-amd64.iso 
                       of=/dev/sdc  status=progress oflag=sync
 

2025/02/11

Long Division without rounding in python

 

 
Though Each language has sufficient datatypes yet for certain situation we need 
more mathematical datatypes,I made an attempt to create division algorithm for 
integer which does not rely on rounding end digits or truncating.
 
The limitation of algorithm is due to inherent behavior of python datatype to 
round fraction especially in case float & inability of Decimal to extract 
required fractions natively.
 
Code: 
 
from decimal import Decimal, getcontext

decimalDivident: int = 918
decimalDivisor: int = 139


# decimalDivident: int = 22
# decimalDivisor: int = 7
counter:int = 0;



print(f"Dividing:'{decimalDivident}' by '{decimalDivisor}'")

class RecurringDecimal:
def __init__(self, decimalValue: str, repeatStart: int, repeatEnd: int,stringValue:float):
self.decimalValue = decimalValue # String representation of the decimal
self.stringValue = stringValue # String representation of the decimal
self.repeatStart = repeatStart # Index where repeating part starts
self.repeatEnd = repeatEnd # Index where repeating part ends

def __repr__(self):
return f"RecurringDecimal(decimal='{self.decimal_value}', repeat_start={self.repeat_start}, repeat_end={self.repeat_end})"

def getDivision(divisor: int,divident:int,requiredDecimalFraction:int) -> RecurringDecimal:
division:int = 0
decimalDivision=0.0
remainder:int = 0
repeateEndIndex:int=-1
immediateDivision:int = 0
fractionPosition:int=-1
noOfDecimalAfterFraction:int=0
noOfDigitsInDivision:int=0
noOfDigitsAfterDecimal:int=0
repeateStartIndex:int=-1
reminderList:list=[]
enhancedDouble:RecurringDecimal

try:
print(f"*requiredDecimalFraction:'{requiredDecimalFraction}'")
while noOfDecimalAfterFraction < requiredDecimalFraction:
remainder = divident % divisor
immediateDivision = divident // divisor

if not remainder in reminderList:
reminderList.append(remainder)
elif remainder in reminderList and repeateStartIndex == -1:
repeateStartIndex = reminderList.index(remainder)
repeateEndIndex = len(reminderList) - repeateStartIndex -1


if(immediateDivision > 0):
division = division * 10 + immediateDivision
else:
division = division * 10

# print(f"*division:'{division}'")
divident = remainder

# print(f"#Before Inner While Loop:")
# print(f"#remainder:'{remainder}'")
# print(f"#divisor:'{divisor}'")

#print(f"In Inner While Loop:")
while remainder < divisor:
noOfDigitsAfterDecimal +=1
remainder = remainder * 10
divident = remainder

if fractionPosition == -1:
fractionPosition = len(str(division))

# print(f"##remainder:'{remainder}'")
# print(f"##divisor:'{divisor}'")
# print(f"##divident:'{divident}'")

if fractionPosition != -1:
noOfDecimalAfterFraction = noOfDecimalAfterFraction + 1

# print(f"**After Inner While Loop:")

if requiredDecimalFraction == noOfDecimalAfterFraction:
# print(f"--->No Of Decimal After Fraction'{noOfDecimalAfterFraction}'")
# print(f"--->Required Fractions Received")
break

if remainder ==0:
# print(f"--->Reminder Become Zero'")
break

# print(f"$$$$ division:'{division}'")
noOfDigitsInDivision = len(str(division))

# print(f"$$$$ fractionPosition:'{fractionPosition}'")
# print(f"$$$$ noOfDigitsInDivision:'{noOfDigitsInDivision}'")

if fractionPosition != -1:
decimalDivision =division / (10 ** (noOfDigitsInDivision - fractionPosition))

num_str = str(Decimal(decimalDivision).normalize())
decimal_part = num_str.split(".")[1] if "." in num_str else ""

print("%%% decimal_part:='{decimal_part}'")

if repeateEndIndex > 0:
stringDivision = num_str.split(".")[0] + "." + decimal_part[:repeateStartIndex + repeateEndIndex+1].ljust(repeateStartIndex + repeateEndIndex+1, '0')
else:
stringDivision = num_str.split(".")[0] + "." + decimal_part[:requiredDecimalFraction].ljust(requiredDecimalFraction, '0')


enhancedDouble=RecurringDecimal(decimalDivision,repeateStartIndex,repeateEndIndex,stringDivision)


print(f"$$$$ noOfDigitsAfterDecimal='{noOfDigitsAfterDecimal-1}' immediateDivision='{immediateDivision}'")
print(f"$$$$ repeateStartIndex='{repeateStartIndex}' repeateEndIndex='{repeateEndIndex}'")

return enhancedDouble
except ZeroDivisionError as e:
print("Error:", e)
raise ZeroDivisionError("Division by zero is not allowed.")

enhancedDouble:RecurringDecimal = getDivision(decimalDivisor,decimalDivident,22)
print(f"Division Result:'{enhancedDouble.decimalValue}',Recurring Start Point:'{enhancedDouble.repeatStart}' Recurring End Point:'{enhancedDouble.repeatEnd}' String Value '{enhancedDouble.stringValue}'")


2025/02/10

Division using Matrix a failed attempt

def reverseNumber(n: int) -> int:
reversed_num = 0
while n > 0:
remainder = n % 10
reversed_num = reversed_num * 10 + remainder
n //= 10 # Floor division
return reversed_num

def create2DimensionalMatrix(rows: int, cols: int, default_value=0) -> list:
return [[default_value for _ in range(cols)] for _ in range(rows)]


def valueOfMatrix(valueMatrix: list) -> float:
returnValue:float=0
for i, row in enumerate(valueMatrix):
for j, value in enumerate(row):
returnValue = returnValue + valueMatrix[i][j]

return returnValue

decimalDividend: int = 918
decimalDivisor: int = 139
decimalDividendRevered: int = reverseNumber(decimalDividend)
decimalDivisorRevered: int = reverseNumber(decimalDivisor)

decimalDividendConstitutent:list=[]
decimalDivisorConstitutent:list=[]

while decimalDividendRevered > 0:
decimalDividendConstitutent.append(decimalDividendRevered%10)
decimalDividendRevered = int(decimalDividendRevered/10)

while decimalDivisorRevered > 0:
decimalDivisorConstitutent.append(decimalDivisorRevered%10)
decimalDivisorRevered = int(decimalDivisorRevered/10)

print(f"% Broken Dividend Decimal Into Constitutent Digits:'{decimalDividendConstitutent}'")
print(f"% Broken Divisor Decimal Into Constitutent Digits:'{decimalDivisorConstitutent}'")

decimalDividendConstitutentReversedList:list = decimalDividendConstitutent[::-1]
decimalDivisorConstitutentReversedList:list = decimalDivisorConstitutent[::-1]

numberOfDigitsInDecimalDividendReveredList:int = len(decimalDividendConstitutentReversedList)
numberOfDigitsInDecimalDivisorReveredList:int = len(decimalDivisorConstitutentReversedList)


divisionMatrix:list = create2DimensionalMatrix(numberOfDigitsInDecimalDividendReveredList,numberOfDigitsInDecimalDivisorReveredList)
remainderMatrix:list = create2DimensionalMatrix(numberOfDigitsInDecimalDividendReveredList,numberOfDigitsInDecimalDivisorReveredList)
valueMatrix:list = create2DimensionalMatrix(numberOfDigitsInDecimalDividendReveredList,numberOfDigitsInDecimalDivisorReveredList)


print(f"No Of Constitutent Digits In Dividend:'{numberOfDigitsInDecimalDividendReveredList}'")
print(f"No Of Constitutent Digits In Divisor: '{numberOfDigitsInDecimalDivisorReveredList}'")

print(f"Nexted Loop Starts Here")

division:int =0
reminder:int =0
k:int =0
valueDecimalFactor:float=0
valueDecimalDividerFactor:float=0
signFactor:int=0
borrowFactor:int=1

twoDimensionalMatrixRowCursorPlaceValue:int =0
twoDimensionalMatrixColumnCursorPlaceValue:int =0

dividentPlaceValue:int = 0
divisorPlaceValue:int = 0

# Assuming lists are of equal length
for i in reversed(range(len(decimalDividendConstitutentReversedList))):
for j in reversed(range(len(decimalDivisorConstitutentReversedList))):
print(f"------Iteration Start------")
print(f"Nexted Loop Cursor Position:")
print(f"i :{i}")
print(f"j :{j}")
print(f"abs(j-2) :{abs(j-2)}")
print(f"abs(i-2) :{abs(i-2)}")

twoDimensionalMatrixRowCursorPlaceValue =numberOfDigitsInDecimalDividendReveredList- i -1
twoDimensionalMatrixColumnCursorPlaceValue =numberOfDigitsInDecimalDivisorReveredList - j -1

if i < j: # Skip loop
print(f"# Skipping Iteration")
continue

print(f"# Decimal Cursored Dividend Digit: {decimalDividendConstitutentReversedList[i]},Cursor At Decimal Index {i}")
print(f"# Decimal Cursored Divisor Digit: {decimalDivisorConstitutentReversedList[j]},Cursor At Decimal Index {j}")

placeValueDividendConstituentReversedListCursoredDigit = decimalDividendConstitutentReversedList[i] * (10 ** i)
placeValueDivisorConstituentReversedListCursoredDigit = decimalDivisorConstitutentReversedList[j] * (10 ** j)

print(f"# Place Value Divisor Constituent Reversed List Cursored Digit: {placeValueDivisorConstituentReversedListCursoredDigit}")
print(f"# Place Value Dividend Constituent Reversed List Cursored Digit: {placeValueDividendConstituentReversedListCursoredDigit}")

# if placeValueDivisorConstituentReversedListCursoredDigit > placeValueDividendConstituentReversedListCursoredDigit : # Skip loop
# print(f"# Skipping Iteration")
# continue



if abs(j-2) < abs(i-2): #col index less than row index
print(f"## Skipping Iteration")
continue

if(decimalDivisorConstitutentReversedList[j] > decimalDividendConstitutentReversedList[i]):
borrowFactor = -1
else:
borrowFactor = 1


division = borrowFactor * placeValueDividendConstituentReversedListCursoredDigit/placeValueDivisorConstituentReversedListCursoredDigit
reminder = placeValueDividendConstituentReversedListCursoredDigit % placeValueDivisorConstituentReversedListCursoredDigit



print(f"## Dividend Constituent Digit Revered List Cursored Digit: {decimalDividendConstitutentReversedList[i]},Occurs At Decimal Index {i},Place Value {placeValueDividendConstituentReversedListCursoredDigit}")
print(f"## Divisor Constituent Digit Revered List Cursored Digit: {decimalDivisorConstitutentReversedList[j]},Occurs At Decimal Index {j},Place Value {placeValueDivisorConstituentReversedListCursoredDigit}")

print(f"### Division:{division}")
print(f"### Reminder:{reminder}")

print(f"###Division Matrix Row Cursor Index:{twoDimensionalMatrixRowCursorPlaceValue}")
print(f"### Division Matrix Column Cursor Index:{twoDimensionalMatrixColumnCursorPlaceValue}")


divisionMatrix [twoDimensionalMatrixRowCursorPlaceValue][twoDimensionalMatrixColumnCursorPlaceValue] = division
remainderMatrix [twoDimensionalMatrixRowCursorPlaceValue][twoDimensionalMatrixColumnCursorPlaceValue] = reminder

dividentCursoredDigitPlaceValue =10 ** (len(str(placeValueDividendConstituentReversedListCursoredDigit))-1)
divisorCursoredDigitPlaceValue =10 ** (len(str(placeValueDivisorConstituentReversedListCursoredDigit))-1)
valueDecimalFactor = (dividentCursoredDigitPlaceValue/divisorCursoredDigitPlaceValue)

print(f"### Divident Cursored Digit Place Value:{dividentCursoredDigitPlaceValue}")
print(f"### Divisor Cursored Digit Place Value:{divisorCursoredDigitPlaceValue}")
print(f"### Value Cursored Digit Place Value:{valueDecimalFactor}")


print(f"numberOfDigitsInDecimalDividendReveredList:{numberOfDigitsInDecimalDividendReveredList}")

k= i+j-4
print(f"k:{k}")

signFactor = (-1)**abs(k)

print(f"signFactor:{signFactor}")

valueDecimalDividerFactor = signFactor * (10 ** abs(k))
print(f"[*]: valueDecimalDividerFactor:{valueDecimalDividerFactor}")

if i+1 == numberOfDigitsInDecimalDividendReveredList and j == 0:
print(f"i inside:{i}")
print(f"j inside:{j}")
valueMatrix [twoDimensionalMatrixRowCursorPlaceValue][twoDimensionalMatrixColumnCursorPlaceValue] = division * 2 / (valueDecimalDividerFactor*10)
else:
valueMatrix [twoDimensionalMatrixRowCursorPlaceValue][twoDimensionalMatrixColumnCursorPlaceValue] = division / valueDecimalDividerFactor

print(f"Divident Cursored Digit Place Value: {dividentCursoredDigitPlaceValue}")
print(f"Divisor Cursored Digit Place Value: {divisorCursoredDigitPlaceValue}")
#valueMatrix [twoDimensionalMatrixRowCursorPlaceValue][twoDimensionalMatrixColumnCursorPlaceValue] = division * ((10 ** j)/(10 ** i))
print(f"------Iteration Ends------")

valueOfDivision:float = valueOfMatrix(valueMatrix)
print(f"#### Division Matrix:'{divisionMatrix}'")
print(f"#### Value Matrix:'{valueMatrix}'")


print(f"#### Value Of Division:'{valueOfDivision}'")