SlideShare a Scribd company logo
1 of 2
#!/bin/bash
die()
{
error=$1
[ -n "$*" ] && printf "%sn" "$*" >&2
exit "$error"
}
install_script()
{
filename=${1%$devel_suffix} ## Command name, without suffix
filename=${filename##*/} ## Remove path; use file name
alone
dest=( $InstalDir/$filename$bin_suffix ## Path to installed file
$WebDir/$filename$devel_suffix ## Web site
)
source=$ScriptDir/$filename$devel_suffix ## Path to development file
_uniqfile $BackupDir/$filename ## Increment backup filename
bak=$_UNIQFILE ## ...and store in $bak
## Check that source file exists
[ -f "$source" ] || die 2 No source file
# [ -x "$source" ] || chmod +x "$source"
## Create destination file to check permissions
[ -f "$dest" ] || touch "$dest" || die 5 Could not touch destination file
chmod u+rwx "$source" "$dest"
if cmp "$source" "$dest" >/dev/null
then ## The files are identical; do nothing
echo "$source and $dest are the same" >&2
elif [ $diff -ge 1 ]
then
diff -c "$source" "$dest"
else
## Copy the production file to the backup directory
[ -s "$dest" ] && cp -p "$dest" "$bak"
## Copy the development script to the production directory/ies
for d in "${dest[@]}"
do
cp -p "$source" "$d"
done
## Remove write permissions
chmod 755 "$dest"
fi
}
install_bash_script()
{
filename=${1%-bash} ## Command name, without suffix
filename=${filename##*/} ## Remove path; use file name
alone
dest=$InstalDir/$filename$bin_suffix ## Path to installed file
source=$ScriptDir/$filename$devel_suffix ## Path to development file
_uniqfile $BackupDir/$filename ## Increment backup filename
bak=$_UNIQFILE ## ...and store in $bak
## Check that source file exists
[ -f "$source" ] || return 2
# [ -x "$source" ] || chmod +x "$source"
## Create destination file to check permissions
[ -f "$dest" ] || touch "$dest" || exit 5
chmod u+rwx "$source" "$dest"
if cmp "$source" "$dest" >/dev/null
then ## The files are identical; do nothing
echo "$source and $dest are the same" >&2
elif [ $diff -ge 1 ]
then
diff -c "$source" "$dest"
else
## Copy the production file to the backup directory
[ -s "$dest" ] && cp -p "$dest" "$bak"
## Copy the development script to the production directory
cp -p "$source" "$dest"
## Remove write permissions
chmod 755 "$dest"
fi
}
progname=${0##*/}
case $progname in
*-sh) shx=-sh ;;
*) shx= ;;
esac
. standard-funcs$shx ## load standard functions
## Use the script-setup configuration file
configfile=$HOME/.config/script-setup.cfg
## If the config file doesn't exist, run script-setup
[ -f $configfile ] || script-setup || exit 5
## Source config file
. $configfile
diff=0
## Parse command-line options
while getopts dc: arg; do
case $arg in
c) configfile=$OPTARG
[ -f "$configfile" ] && . "$configfile"
;;
d) diff=1 ;;
*) exit 1 ;;
esac
done
shift "$(( $OPTIND - 1 ))"
## This is only necessary when a hand-rolled config file is used
#checkdirs $HOME/.config "$ScriptDir" "$BinDir" "$BackupDir" ||
# die $? "Could not create $dir"
## Install all commands given on the command line
for script
do
install_script "$script"
done

More Related Content

What's hot

20 modules i haven't yet talked about
20 modules i haven't yet talked about20 modules i haven't yet talked about
20 modules i haven't yet talked about
Tatsuhiko Miyagawa
 
Advanced modulinos
Advanced modulinosAdvanced modulinos
Advanced modulinos
brian d foy
 
C A S Sample Php
C A S Sample PhpC A S Sample Php
C A S Sample Php
JH Lee
 
PerlでWeb API入門
PerlでWeb API入門PerlでWeb API入門
PerlでWeb API入門
Yusuke Wada
 
Logrotate sh
Logrotate shLogrotate sh
Logrotate sh
Ben Pope
 
News of the Symfony2 World
News of the Symfony2 WorldNews of the Symfony2 World
News of the Symfony2 World
Fabien Potencier
 

What's hot (20)

Pemrograman Web 8 - MySQL
Pemrograman Web 8 - MySQLPemrograman Web 8 - MySQL
Pemrograman Web 8 - MySQL
 
Not Really PHP by the book
Not Really PHP by the bookNot Really PHP by the book
Not Really PHP by the book
 
Bag of tricks
Bag of tricksBag of tricks
Bag of tricks
 
[2019] 아직도 돈 주고 DB 쓰나요? for Developer
[2019] 아직도 돈 주고 DB 쓰나요? for Developer[2019] 아직도 돈 주고 DB 쓰나요? for Developer
[2019] 아직도 돈 주고 DB 쓰나요? for Developer
 
20 modules i haven't yet talked about
20 modules i haven't yet talked about20 modules i haven't yet talked about
20 modules i haven't yet talked about
 
Php
PhpPhp
Php
 
Advanced modulinos
Advanced modulinosAdvanced modulinos
Advanced modulinos
 
spug_2008-08
spug_2008-08spug_2008-08
spug_2008-08
 
Ch3(working with file)
Ch3(working with file)Ch3(working with file)
Ch3(working with file)
 
Advanced modulinos trial
Advanced modulinos trialAdvanced modulinos trial
Advanced modulinos trial
 
Uncovering Iterators
Uncovering IteratorsUncovering Iterators
Uncovering Iterators
 
Php talk
Php talkPhp talk
Php talk
 
C A S Sample Php
C A S Sample PhpC A S Sample Php
C A S Sample Php
 
PerlでWeb API入門
PerlでWeb API入門PerlでWeb API入門
PerlでWeb API入門
 
Perl Fitxers i Directoris
Perl Fitxers i DirectorisPerl Fitxers i Directoris
Perl Fitxers i Directoris
 
Logrotate sh
Logrotate shLogrotate sh
Logrotate sh
 
Node.js - Demnächst auf einem Server in Ihrer Nähe
Node.js - Demnächst auf einem Server in Ihrer NäheNode.js - Demnächst auf einem Server in Ihrer Nähe
Node.js - Demnächst auf einem Server in Ihrer Nähe
 
News of the Symfony2 World
News of the Symfony2 WorldNews of the Symfony2 World
News of the Symfony2 World
 
HappyKardashian.com for #FVCP
HappyKardashian.com for #FVCPHappyKardashian.com for #FVCP
HappyKardashian.com for #FVCP
 
Pagination in PHP
Pagination in PHPPagination in PHP
Pagination in PHP
 

Viewers also liked

Menu func-sh
Menu func-shMenu func-sh
Menu func-sh
Ben Pope
 
Menu func-sh(1)
Menu func-sh(1)Menu func-sh(1)
Menu func-sh(1)
Ben Pope
 
Programming collaborative-ref
Programming collaborative-refProgramming collaborative-ref
Programming collaborative-ref
Ben Pope
 
An a z index of windows power shell commandss
An a z index of windows power shell commandssAn a z index of windows power shell commandss
An a z index of windows power shell commandss
Ben Pope
 
An a z index of the bash commands
An a z index of the bash commandsAn a z index of the bash commands
An a z index of the bash commands
Ben Pope
 
Compound var
Compound varCompound var
Compound var
Ben Pope
 
Xz file-format-1.0.4
Xz file-format-1.0.4Xz file-format-1.0.4
Xz file-format-1.0.4
Ben Pope
 
Applecmdlista zs
Applecmdlista zsApplecmdlista zs
Applecmdlista zs
Ben Pope
 
Getfilestruct zbksh
Getfilestruct zbkshGetfilestruct zbksh
Getfilestruct zbksh
Ben Pope
 
Getfilestruct zbksh(1)
Getfilestruct zbksh(1)Getfilestruct zbksh(1)
Getfilestruct zbksh(1)
Ben Pope
 

Viewers also liked (16)

Menu func-sh
Menu func-shMenu func-sh
Menu func-sh
 
Menu func-sh(1)
Menu func-sh(1)Menu func-sh(1)
Menu func-sh(1)
 
Pop3stat sh
Pop3stat shPop3stat sh
Pop3stat sh
 
Phdel sh
Phdel shPhdel sh
Phdel sh
 
Popstat1 sh
Popstat1 shPopstat1 sh
Popstat1 sh
 
Phadd sh
Phadd shPhadd sh
Phadd sh
 
Luhn sh
Luhn shLuhn sh
Luhn sh
 
Programming collaborative-ref
Programming collaborative-refProgramming collaborative-ref
Programming collaborative-ref
 
An a z index of windows power shell commandss
An a z index of windows power shell commandssAn a z index of windows power shell commandss
An a z index of windows power shell commandss
 
An a z index of the bash commands
An a z index of the bash commandsAn a z index of the bash commands
An a z index of the bash commands
 
Compound var
Compound varCompound var
Compound var
 
Xz file-format-1.0.4
Xz file-format-1.0.4Xz file-format-1.0.4
Xz file-format-1.0.4
 
Applecmdlista zs
Applecmdlista zsApplecmdlista zs
Applecmdlista zs
 
Getfilestruct zbksh
Getfilestruct zbkshGetfilestruct zbksh
Getfilestruct zbksh
 
Getfilestruct zbksh(1)
Getfilestruct zbksh(1)Getfilestruct zbksh(1)
Getfilestruct zbksh(1)
 
Pop3ck sh
Pop3ck shPop3ck sh
Pop3ck sh
 

Similar to Cpsh sh

On secure application of PHP wrappers
On secure application  of PHP wrappersOn secure application  of PHP wrappers
On secure application of PHP wrappers
Positive Hack Days
 

Similar to Cpsh sh (20)

Unix 5 en
Unix 5 enUnix 5 en
Unix 5 en
 
BASH Variables Part 1: Basic Interpolation
BASH Variables Part 1: Basic InterpolationBASH Variables Part 1: Basic Interpolation
BASH Variables Part 1: Basic Interpolation
 
10 tips for making Bash a sane programming language
10 tips for making Bash a sane programming language10 tips for making Bash a sane programming language
10 tips for making Bash a sane programming language
 
Perl basics for Pentesters
Perl basics for PentestersPerl basics for Pentesters
Perl basics for Pentesters
 
Shell实现的windows回收站功能的脚本
Shell实现的windows回收站功能的脚本Shell实现的windows回收站功能的脚本
Shell实现的windows回收站功能的脚本
 
Unix 1st sem lab programs a - VTU Karnataka
Unix 1st sem lab programs a - VTU KarnatakaUnix 1st sem lab programs a - VTU Karnataka
Unix 1st sem lab programs a - VTU Karnataka
 
Git installation
Git installationGit installation
Git installation
 
Docker tips & tricks
Docker  tips & tricksDocker  tips & tricks
Docker tips & tricks
 
Shell scripting
Shell scriptingShell scripting
Shell scripting
 
Efficient DBA: Gain Time by Reducing Command-Line Keystrokes
Efficient DBA: Gain Time by Reducing Command-Line KeystrokesEfficient DBA: Gain Time by Reducing Command-Line Keystrokes
Efficient DBA: Gain Time by Reducing Command-Line Keystrokes
 
Phishing for Root (How I Got Access to Root on Your Computer With 8 Seconds o...
Phishing for Root (How I Got Access to Root on Your Computer With 8 Seconds o...Phishing for Root (How I Got Access to Root on Your Computer With 8 Seconds o...
Phishing for Root (How I Got Access to Root on Your Computer With 8 Seconds o...
 
Simple Ways To Be A Better Programmer (OSCON 2007)
Simple Ways To Be A Better Programmer (OSCON 2007)Simple Ways To Be A Better Programmer (OSCON 2007)
Simple Ways To Be A Better Programmer (OSCON 2007)
 
On secure application of PHP wrappers
On secure application  of PHP wrappersOn secure application  of PHP wrappers
On secure application of PHP wrappers
 
Module 03 Programming on Linux
Module 03 Programming on LinuxModule 03 Programming on Linux
Module 03 Programming on Linux
 
The Unbearable Lightness: Extending the Bash shell
The Unbearable Lightness: Extending the Bash shellThe Unbearable Lightness: Extending the Bash shell
The Unbearable Lightness: Extending the Bash shell
 
clonehd01
clonehd01clonehd01
clonehd01
 
Bash Scripting Workshop
Bash Scripting WorkshopBash Scripting Workshop
Bash Scripting Workshop
 
Raspberry pi Part 25
Raspberry pi Part 25Raspberry pi Part 25
Raspberry pi Part 25
 
Lets make better scripts
Lets make better scriptsLets make better scripts
Lets make better scripts
 
Bash is not a second zone citizen programming language
Bash is not a second zone citizen programming languageBash is not a second zone citizen programming language
Bash is not a second zone citizen programming language
 

Recently uploaded

➥🔝 7737669865 🔝▻ Bangalore Call-girls in Women Seeking Men 🔝Bangalore🔝 Esc...
➥🔝 7737669865 🔝▻ Bangalore Call-girls in Women Seeking Men  🔝Bangalore🔝   Esc...➥🔝 7737669865 🔝▻ Bangalore Call-girls in Women Seeking Men  🔝Bangalore🔝   Esc...
➥🔝 7737669865 🔝▻ Bangalore Call-girls in Women Seeking Men 🔝Bangalore🔝 Esc...
amitlee9823
 
Call Girls In Attibele ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Attibele ☎ 7737669865 🥵 Book Your One night StandCall Girls In Attibele ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Attibele ☎ 7737669865 🥵 Book Your One night Stand
amitlee9823
 
Call Girls Bommasandra Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
Call Girls Bommasandra Just Call 👗 7737669865 👗 Top Class Call Girl Service B...Call Girls Bommasandra Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
Call Girls Bommasandra Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
amitlee9823
 
Call Girls Indiranagar Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
Call Girls Indiranagar Just Call 👗 7737669865 👗 Top Class Call Girl Service B...Call Girls Indiranagar Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
Call Girls Indiranagar Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
amitlee9823
 
Mg Road Call Girls Service: 🍓 7737669865 🍓 High Profile Model Escorts | Banga...
Mg Road Call Girls Service: 🍓 7737669865 🍓 High Profile Model Escorts | Banga...Mg Road Call Girls Service: 🍓 7737669865 🍓 High Profile Model Escorts | Banga...
Mg Road Call Girls Service: 🍓 7737669865 🍓 High Profile Model Escorts | Banga...
amitlee9823
 
Call Girls In Shalimar Bagh ( Delhi) 9953330565 Escorts Service
Call Girls In Shalimar Bagh ( Delhi) 9953330565 Escorts ServiceCall Girls In Shalimar Bagh ( Delhi) 9953330565 Escorts Service
Call Girls In Shalimar Bagh ( Delhi) 9953330565 Escorts Service
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
FESE Capital Markets Fact Sheet 2024 Q1.pdf
FESE Capital Markets Fact Sheet 2024 Q1.pdfFESE Capital Markets Fact Sheet 2024 Q1.pdf
FESE Capital Markets Fact Sheet 2024 Q1.pdf
MarinCaroMartnezBerg
 
Call Girls In Hsr Layout ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Hsr Layout ☎ 7737669865 🥵 Book Your One night StandCall Girls In Hsr Layout ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Hsr Layout ☎ 7737669865 🥵 Book Your One night Stand
amitlee9823
 
Al Barsha Escorts $#$ O565212860 $#$ Escort Service In Al Barsha
Al Barsha Escorts $#$ O565212860 $#$ Escort Service In Al BarshaAl Barsha Escorts $#$ O565212860 $#$ Escort Service In Al Barsha
Al Barsha Escorts $#$ O565212860 $#$ Escort Service In Al Barsha
AroojKhan71
 
Jual Obat Aborsi Surabaya ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Surabaya ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Surabaya ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Surabaya ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
ZurliaSoop
 

Recently uploaded (20)

➥🔝 7737669865 🔝▻ Bangalore Call-girls in Women Seeking Men 🔝Bangalore🔝 Esc...
➥🔝 7737669865 🔝▻ Bangalore Call-girls in Women Seeking Men  🔝Bangalore🔝   Esc...➥🔝 7737669865 🔝▻ Bangalore Call-girls in Women Seeking Men  🔝Bangalore🔝   Esc...
➥🔝 7737669865 🔝▻ Bangalore Call-girls in Women Seeking Men 🔝Bangalore🔝 Esc...
 
Call Girls In Attibele ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Attibele ☎ 7737669865 🥵 Book Your One night StandCall Girls In Attibele ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Attibele ☎ 7737669865 🥵 Book Your One night Stand
 
Call Girls Bommasandra Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
Call Girls Bommasandra Just Call 👗 7737669865 👗 Top Class Call Girl Service B...Call Girls Bommasandra Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
Call Girls Bommasandra Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
 
Call Girls Indiranagar Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
Call Girls Indiranagar Just Call 👗 7737669865 👗 Top Class Call Girl Service B...Call Girls Indiranagar Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
Call Girls Indiranagar Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
 
Mg Road Call Girls Service: 🍓 7737669865 🍓 High Profile Model Escorts | Banga...
Mg Road Call Girls Service: 🍓 7737669865 🍓 High Profile Model Escorts | Banga...Mg Road Call Girls Service: 🍓 7737669865 🍓 High Profile Model Escorts | Banga...
Mg Road Call Girls Service: 🍓 7737669865 🍓 High Profile Model Escorts | Banga...
 
Call Girls In Shalimar Bagh ( Delhi) 9953330565 Escorts Service
Call Girls In Shalimar Bagh ( Delhi) 9953330565 Escorts ServiceCall Girls In Shalimar Bagh ( Delhi) 9953330565 Escorts Service
Call Girls In Shalimar Bagh ( Delhi) 9953330565 Escorts Service
 
Discover Why Less is More in B2B Research
Discover Why Less is More in B2B ResearchDiscover Why Less is More in B2B Research
Discover Why Less is More in B2B Research
 
Halmar dropshipping via API with DroFx
Halmar  dropshipping  via API with DroFxHalmar  dropshipping  via API with DroFx
Halmar dropshipping via API with DroFx
 
(NEHA) Call Girls Katra Call Now 8617697112 Katra Escorts 24x7
(NEHA) Call Girls Katra Call Now 8617697112 Katra Escorts 24x7(NEHA) Call Girls Katra Call Now 8617697112 Katra Escorts 24x7
(NEHA) Call Girls Katra Call Now 8617697112 Katra Escorts 24x7
 
Cheap Rate Call girls Sarita Vihar Delhi 9205541914 shot 1500 night
Cheap Rate Call girls Sarita Vihar Delhi 9205541914 shot 1500 nightCheap Rate Call girls Sarita Vihar Delhi 9205541914 shot 1500 night
Cheap Rate Call girls Sarita Vihar Delhi 9205541914 shot 1500 night
 
Invezz.com - Grow your wealth with trading signals
Invezz.com - Grow your wealth with trading signalsInvezz.com - Grow your wealth with trading signals
Invezz.com - Grow your wealth with trading signals
 
Call me @ 9892124323 Cheap Rate Call Girls in Vashi with Real Photo 100% Secure
Call me @ 9892124323  Cheap Rate Call Girls in Vashi with Real Photo 100% SecureCall me @ 9892124323  Cheap Rate Call Girls in Vashi with Real Photo 100% Secure
Call me @ 9892124323 Cheap Rate Call Girls in Vashi with Real Photo 100% Secure
 
FESE Capital Markets Fact Sheet 2024 Q1.pdf
FESE Capital Markets Fact Sheet 2024 Q1.pdfFESE Capital Markets Fact Sheet 2024 Q1.pdf
FESE Capital Markets Fact Sheet 2024 Q1.pdf
 
April 2024 - Crypto Market Report's Analysis
April 2024 - Crypto Market Report's AnalysisApril 2024 - Crypto Market Report's Analysis
April 2024 - Crypto Market Report's Analysis
 
Week-01-2.ppt BBB human Computer interaction
Week-01-2.ppt BBB human Computer interactionWeek-01-2.ppt BBB human Computer interaction
Week-01-2.ppt BBB human Computer interaction
 
Call Girls In Hsr Layout ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Hsr Layout ☎ 7737669865 🥵 Book Your One night StandCall Girls In Hsr Layout ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Hsr Layout ☎ 7737669865 🥵 Book Your One night Stand
 
VIP Model Call Girls Hinjewadi ( Pune ) Call ON 8005736733 Starting From 5K t...
VIP Model Call Girls Hinjewadi ( Pune ) Call ON 8005736733 Starting From 5K t...VIP Model Call Girls Hinjewadi ( Pune ) Call ON 8005736733 Starting From 5K t...
VIP Model Call Girls Hinjewadi ( Pune ) Call ON 8005736733 Starting From 5K t...
 
Al Barsha Escorts $#$ O565212860 $#$ Escort Service In Al Barsha
Al Barsha Escorts $#$ O565212860 $#$ Escort Service In Al BarshaAl Barsha Escorts $#$ O565212860 $#$ Escort Service In Al Barsha
Al Barsha Escorts $#$ O565212860 $#$ Escort Service In Al Barsha
 
Jual Obat Aborsi Surabaya ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Surabaya ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Surabaya ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Surabaya ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
 
Generative AI on Enterprise Cloud with NiFi and Milvus
Generative AI on Enterprise Cloud with NiFi and MilvusGenerative AI on Enterprise Cloud with NiFi and Milvus
Generative AI on Enterprise Cloud with NiFi and Milvus
 

Cpsh sh

  • 1. #!/bin/bash die() { error=$1 [ -n "$*" ] && printf "%sn" "$*" >&2 exit "$error" } install_script() { filename=${1%$devel_suffix} ## Command name, without suffix filename=${filename##*/} ## Remove path; use file name alone dest=( $InstalDir/$filename$bin_suffix ## Path to installed file $WebDir/$filename$devel_suffix ## Web site ) source=$ScriptDir/$filename$devel_suffix ## Path to development file _uniqfile $BackupDir/$filename ## Increment backup filename bak=$_UNIQFILE ## ...and store in $bak ## Check that source file exists [ -f "$source" ] || die 2 No source file # [ -x "$source" ] || chmod +x "$source" ## Create destination file to check permissions [ -f "$dest" ] || touch "$dest" || die 5 Could not touch destination file chmod u+rwx "$source" "$dest" if cmp "$source" "$dest" >/dev/null then ## The files are identical; do nothing echo "$source and $dest are the same" >&2 elif [ $diff -ge 1 ] then diff -c "$source" "$dest" else ## Copy the production file to the backup directory [ -s "$dest" ] && cp -p "$dest" "$bak" ## Copy the development script to the production directory/ies for d in "${dest[@]}" do cp -p "$source" "$d" done ## Remove write permissions chmod 755 "$dest" fi } install_bash_script() { filename=${1%-bash} ## Command name, without suffix filename=${filename##*/} ## Remove path; use file name alone dest=$InstalDir/$filename$bin_suffix ## Path to installed file source=$ScriptDir/$filename$devel_suffix ## Path to development file _uniqfile $BackupDir/$filename ## Increment backup filename bak=$_UNIQFILE ## ...and store in $bak ## Check that source file exists [ -f "$source" ] || return 2 # [ -x "$source" ] || chmod +x "$source"
  • 2. ## Create destination file to check permissions [ -f "$dest" ] || touch "$dest" || exit 5 chmod u+rwx "$source" "$dest" if cmp "$source" "$dest" >/dev/null then ## The files are identical; do nothing echo "$source and $dest are the same" >&2 elif [ $diff -ge 1 ] then diff -c "$source" "$dest" else ## Copy the production file to the backup directory [ -s "$dest" ] && cp -p "$dest" "$bak" ## Copy the development script to the production directory cp -p "$source" "$dest" ## Remove write permissions chmod 755 "$dest" fi } progname=${0##*/} case $progname in *-sh) shx=-sh ;; *) shx= ;; esac . standard-funcs$shx ## load standard functions ## Use the script-setup configuration file configfile=$HOME/.config/script-setup.cfg ## If the config file doesn't exist, run script-setup [ -f $configfile ] || script-setup || exit 5 ## Source config file . $configfile diff=0 ## Parse command-line options while getopts dc: arg; do case $arg in c) configfile=$OPTARG [ -f "$configfile" ] && . "$configfile" ;; d) diff=1 ;; *) exit 1 ;; esac done shift "$(( $OPTIND - 1 ))" ## This is only necessary when a hand-rolled config file is used #checkdirs $HOME/.config "$ScriptDir" "$BinDir" "$BackupDir" || # die $? "Could not create $dir" ## Install all commands given on the command line for script do install_script "$script" done