Split Music Image in Debian

Share my script used to split music image file into indivdual track of wav or flac

OS: Debian/ununtu

Install necessary tool:

sudo apt-get clean

sudo apt-get update

sudo apt-get install -y shntool dos2unix enca flac ffmpeg

Convert

# output track in wav format

sudo split.sh CDImage.wav wav

# output track in flac format

sudo split.sh CDImage.wav flac

Split.sh

#/bin/bash

if [ $# -ne 2 ] && [ $# -ne 1 ]
then

echo "Usage:   sudo split.sh FILE [DECODE]"
echo "Example: sudo split.sh CDImage wav"
echo "         sudo split.sh CDImage flac"
echo "         sudo split.sh CDImage.wav"
echo "         sudo split.sh CDImage.wav flac"
echo "         sudo split.sh CDImage"
echo "Note:"
echo "         The Input Audio File =   FILE.wav or FILE.flac or FILE.ape"
echo "         DECODE               =   wav or flac (Output Audio Format)"
echo "         The Input CUE File   =   FILE.cue"
exit

fi


BFILE=$1

if [ -f ${BFILE} ];then
  AUDIO_FILE=${BFILE}
  EXT=${BFILE##*.}
  case $EXT in
    "wav"|"WAV")
       FORMAT="wav"
       ;;
    "flac"|"FLAC")
       FORMAT="flac"
       ;;
    "ape"|"APE")
       FORMAT="ape"
       ;;
    esac
else if [ -f $BFILE.wav ];then
       AUDIO_FILE=$BFILE.wav
       FORMAT="wav"
     else if [ -f $BFILE.flac ];then
             AUDIO_FILE=$BFILE.flac
             FORMAT="flac"
          else if [ -f $BFILE.ape ];then
                 AUDIO_FILE=$BFILE.ape
                 FORMAT="ape"
               else
                 echo "Not found audio file: $1.wav or $1.flac or $1.ape "
                 echo "Exit"
                 exit
               fi
          fi  
     fi
fi


if [ $# -ne 1 ];then
DECODE=$2
fi

if [ "A${DECODE}B" = "AB" ];then
  DECODE="wav"
fi


if [ "A${FORMAT}B" = "AB" ];then
  FORMAT="${DECODE}"
fi

if [ "A${DECODE}B" = "AapeB" ];then
  DECODE="wav"
fi


echo "Audio  File   = ${AUDIO_FILE}"
echo "Input  Format = ${FORMAT} " 
echo "Output Format = ${DECODE} "


if [ "$FORMAT" = "ape" ]
then
echo -e "First, convert ape format to ${DECODE} format, waite a minute..."
DECODE_FILE=$BFILE.${DECODE}
#avconv -i "$AUDIO_FILE" "$DECODE_FILE"
ffmpeg -i "$AUDIO_FILE" "$DECODE_FILE"
AUDIO_FILE=$DECODE_FILE
CONVERT="true"
FORMAT="${DECODE}"
fi


#if [ ! "$DECODE" = "$FORMAT" ];then
#echo -e "First, convert ${FORMAT} format to ${DECODE} format, waite a 
#minute..."
#DECODE_FILE=$BFILE.${DECODE}
#avconv -i "$AUDIO_FILE" "$DECODE_FILE"
#ffmpeg -i "$AUDIO_FILE" "$DECODE_FILE"
#AUDIO_FILE=$DECODE_FILE
#CONVERT="true"
#fi


CUE_FILE=$BFILE.cue
CUE_FILE_LINUX=$BFILE-linux.cue

if [ ! -f ${CUE_FILE} ];then
  MY_DIR="`dirname ${BFILE}`"
  MY_NAME="`basename ${BFILE}`"
  MY_BASE="${MY_NAME%.*}"
  CUE_FILE=${MY_DIR}/${MY_BASE}.cue
  if [ ! -f ${CUE_FILE} ];then
   echo "unable to find cue file of:"
   echo "  $BFILE.cue or ${CUE_FILE} "
   exit
  fi
fi

CODE="`enca ${CUE_FILE} |grep ";"|sed "s/.*; //"`"
echo "CODE=${CODE}"

echo iconv -f "${CODE}" -t utf8 "$CUE_FILE" -o "$CUE_FILE_LINUX"

iconv -f "${CODE}" -t utf8 "$CUE_FILE" -o "$CUE_FILE_LINUX"


dos2unix "$CUE_FILE_LINUX"


echo shntool split -t "%n-%t" -f "$CUE_FILE_LINUX" -o $DECODE "$AUDIO_FILE"
shntool split -t "%n-%t" -f "$CUE_FILE_LINUX" -o $DECODE "$AUDIO_FILE"


if [ "$CONVERT" = "true" ]
then
if [ ! "AB" = "A${DECODE_FILE}B" ];then
  if [ -f ${DECODE_FILE} ];then
   echo -e "Remove temporary flac file: $DECODE_FILE"
   rm -f "$DECODE_FILE"
  fi
fi

fi

Install DenyHosts on Linux VPS

#!/bin/bash
PKG_VER=2.10
PKG_DIR=denyhosts-${PKG_VER}
PKG_TAR=${PKG_DIR}.tar.gz
PKG_URL=https://sourceforge.net/projects/denyhosts/files/denyhosts/${PKG_VER}

rm ${PKG_TAR}
rm -rf ${PKG_DIR}
wget –no-check-certificate  ${PKG_URL}/${PKG_TAR}
tar xvfz ${PKG_TAR}

sudo mv ${PKG_DIR}/ /usr/share/denyhosts

cd /usr/share/denyhosts/
sudo cp denyhosts.conf /etc

CFG=/etc/denyhosts.conf
sudo sed -i “s/DENY_THRESHOLD_ROOT = 1/DENY_THRESHOLD_ROOT = 8/” ${CFG}
sudo sed -i “s/ADMIN_EMAIL = root@localhost/ADMIN_EMAIL = /” ${CFG}

sudo cp denyhosts.py /usr/sbin/denyhosts
sudo mv daemon-control-dist daemon-control

cd /etc/init.d
sudo ln -s /usr/share/denyhosts/daemon-control denyhosts
sudo touch /var/log/auth.log
sudo update-rc.d denyhosts start
sudo /etc/init.d/denyhosts start

 

 

iLO4 2.78

The iLO4 2.78  (2021/05/07) of HP MicroServer Gen:

HTML5 Integrated Remote Console

The HTML5 IRC provides remote access to the system KVM and control of Virtual Media from a single console that runs in a supported browser.
 

 

 

mysql server with GTID log-bin

Mysql Master Server:

     ARGU+=” –gtid-mode=ON “
     ARGU+=” –enforce-gtid-consistency=TRUE “
     ARGU+=” –log-slave-updates=FALSE “
     ARGU+=” –log-bin=/opt/local/data/mysqld/mysql-bin “

 

Mysql Slave Server:

     ARGU+=” –relay_log=/opt/local/data/mysqld/relay-bin “
     ARGU+=” –read_only=on “
     ARGU+=” –skip_slave_start=on “

 

Launch Mysl Server:

      mysqld     ${ARGU}     ${OTHER_ARGU} 

Display Master Status:
       mysql>  show master status;

Display Master Status:
      mysql>  show slave status;

Display uuid:
      mysql>  show GLOBAL VARIABLES like ‘server_uuid’;

Display gtid variable:
      mysql>  mysql> show variables like ‘%gtid%’;

 

 

 

 

 

Config NUT for CyberPower VAL600 UPS with TrueNAS Core 12.0-U6

     Master NAS,   PC/TrueNAS Core attached with UPS USB Cable

  • Step 1:   Power on the Cyberpower VAL600 & plug the USB cable into TrueNas system

  • Step 2:   Find out UPS port information, say ugen3.0

TrueNAS Web Gui / System/Advance/Show Console Message

  • Step 3:   Config with the UPS

TrueNAS Web Gui / Services/UPS

UPS Mode:  Master

Remote Monitor:    Enable

Monitor User:      upsmon

Monitor Password:   Your Passwrod

Driver:  Cyber Power System ups2 Value 600E USB

Port or Hostname:   /dev/ugen0.3auto

Shutdown Command:  shutdown -h now

  • Step 4:  Check with command upsc ups@localhost

TrueNAS Web Gui / Shell

  • Step 5:   Verify shutdown command is working by turn off the AC power supplier of UPS

     Slave NAS:    PC/TrueNAS Core not  attached with UPS USB Cable

  • Step 6:Config TrueNAS PC as NUT Salve

UPS Mode:     Slave

Remote Host:   IP of Master NAS

Remote Port:    3493

Port or Hostname:  auto

Monitor User:     upsmon

Monitor Password:    Same as Master UPS

Shutdown command:     shutdown -h now

     Slave Linux:    PC/Linux not  attached with UPS USB Cable

  • Step 7: Config Linux PC as NUT slave

Install NUT

Config upsmon as following

POWERDOWNFLAG /etc/nut/killpower
               MONITOR ups@MASTER_UPS_IP 1  upsmon YOUR_PASSWORD  slave
               MINSUPPLIES 1
               SHUTDOWNCMD “/sbin/shutdown -h +0”

               POLLFREQ 5
               POLLFREQALERT 5
               HOSTSYNC 15
               DEADTIME 15
               RBWARNTIME 43200
               NOCOMMWARNTIME 300
               FINALDELAY 5

Launch upsmon service

Note:

TrueNAS Core only support  UPS On Battery Action

Using CyberPower UPS to keep NAS data safety

The CyberPower VALUE600ELCD UPS is supported by NUT, it can be used to switch off the NAS and computer system when main power fail, for the purpose to keep data and disk safety.

 

NUT,  Network UPS Tools

A suite of open source software component designed for UPS

 

Architect of NUT:   

Kernel:                USB HID Class driver

User Space:       Three linux daemon design

Driver Daemon:  usbhid_ups,   usb hid based protocol

upsd Daemon:   API for client, including upsmon

upsmon Daemon:   monit events from UPSD, and action by launch the pre-defined script

 

Install NUT under ubuntu or debian:

sudo apt-get install -y nut

 

NUT Config  for CyberPower VALUE600ELCD

Modify 4 config file in /etc/nut, by adding following lines

nut.conf:

    MODE=standalone

 

ups.conf
   [cyberpower]
     driver = usbhid-ups
     port = auto
     desc = “CP1500 AVR UPS”
     offdelay = 20
     ondelay = 0
     ignorelb
     override.battery.charge.low = 20
     override.battery.charge.warning = 40
     pollinterval = 15

upsd.conf

    [admin]
         password = 123456
         actions = SET
         instcmds = ALL

   [upsmonuser]
        password = 123456
        upsmon master

upsmon.conf

      MONITOR cyberpower@localhost 1 upsmon 123456 master

 

 

  • Start  or Stop   NUT driver :

             sudo upsdrvctl start

             sudo upsdrvctl stop

 

  • Start/Stop NUT server:

            sudo upsd

            sudo upsd -c stop

 

  • Start/Stop monit Daemon

            sudo upsmon

            sudo upsmon -c stop

 

  • Display UPS status:

            sudo upsc cyberpower@localhost

 

 

 

 

TOSHIBA P300 failing in 5 month

It is reported that one harddisk is failling during boot time of PC,

Error log:

SMART overall-health self-assessment test result: FAILED!
Drive failure expected in less than 24 hours. SAVE ALL DATA.
Failed Attributes:
ID# ATTRIBUTE_NAME          FLAG     VALUE WORST THRESH TYPE      UPDATED  WHEN_FAILED RAW_VALUE
  5 Reallocated_Sector_Ct   0x0033   002   002   005    Pre-fail  Always   FAILING_NOW 1933

 

Disk Model:    TOSHIBA P300 

Supplier:         JD.com

Purchased Date:    2021/05

Report Date:           2021/10

Usage:   SWAP

 

How to check disk status:

smartctl -H /dev/sda

How to make disk test:

smartctl -t long /dev/sda

How to get disk test report:

smartctl -l error /dev/sda

FreeNAS

 Two TrueNAS (FreeNAS)  NAS system are setup for the purpose of data backup, including the resumed blog running on ESXi virtual machine, replaced the Buffalo lS-WXL and WdMycloud.

The benefit of FreeNAS:

  • Based on Freebsd OS, stable
  • Native support ZFS, and snapshot
  • Other professional feature ready

 

The blog data is backup into the 1st FreeNAS, manually after updating the blog.

The 1st FreeNas will generate a snapshot every day, thanks to the Periodic Snapshot Task provided by FreeNAS system, and them replicate the snapshot to the 2nd FreeNas machine, also thanks to the Replication Task of freeNas system.

 

Hardware spec of 1st NAS:

  1. HP T610 plus thin client  ( AMD (G-T56N) 1.65GHz dual core / E350 )
  2. 16GB DDR3  (2 X 8GB)
  3. 32GB Flash driver  for FreeNAS system + 4TB 3.5 HD for data
  4. 10/100/1000  Ethernet

 

    Cost: without Data Disk:

             AMD T610 Plus                               RMB 185
             Power:19V4.74  7.4*5.0mm         RMB 30
             SATA2 32G SSD                            RMB 45
             DDR3L 8G/1600  X2                       RMB 398
———————————————————————–
                 Total                                            RMB 658      

 

 

Hardware spec of 2st NAS:

  1. HP Z220 MT workstation
  2. 32GB DRR3 ECC RAM
  3. Intel G3250T CPU
  4. One USB key for FreeNAS system + 10T HD for data

 

The Raid sub-system is not a best choice.

As Home User, we don’t care about the data lost, or data server down in a short period of time.  That’s way we two NAS system / Data replication instead of raid sub-system.