Pkgman - a bash script for local package and PKGBUILD management
hi all,
here is a script which manages a local repository and lets you edit
PKGBUILDs and other related files, automatically generates checksums,
build packages, add them to your local repo and so on.
it also has AUR support for submitting tarballs, leaving comments, etc.
get it from here:
http://sourceforge.net/projects/pkgman/
and AUR package:
http://aur.archlinux.org/packages.php?ID=17100
you need abs, curl and pacman and optionally namcap and desktop-file-utils.
RTFM online:
http://sourceforge.net/apps/mediawiki/p … n_man_page
first of all copy the pkgman.conf and AUR.conf files from /usr/share/pkgman to ~/.config/pkgman/ or ${XDG_CONFIG_HOME}/pkgman - if ${XDG_CONFIG_HOME} is set,
edit these two files and then run
pkgman --runmefirst
pkgman doesn´t install anything. if you want it just builds the package and moves it to your local repository. install it then with pacman.
it also has no dependency handling. there are many other tools which provide this.
the main intention was to keep track of package versions, different PKGBUILD versions and own AUR submitted tarballs; also to keep a clean local repository and clean build directories.
pkgman is stable now. i´m using it for months without any issues.
however, if there are problems or feedback please post them here.
vlad
changelog:
version 2.4:
*pkgman now respects the PKGDEST and SRCDEST variables from makepkg.conf. (though it still moves the src.tar.gz and .pkg.tar.gz to package backup directory).
version 2.5:
*pkgman uses PKGDEST if SRCDEST not set in makepkg.conf.
version 2.6 -> r26:
*changed version system: version 2.6 is now r26!
*minor changes: > pkgman uses now the $SHELL variable.
> new and more comprehensible manpage description (thanks to bender02)
version r27:
*changed SRCDEST since it's only a cache dir. all files (pkg.tar.gz and src.tar.gz) go to PKGDEST.
version r28:
*added new variable ShellCommand to pkgman.conf. Default is $SHELL.
*One might use an external application (like screen or xterm) to switch to build directory and edit files simultaneously.
version r30:
*minor changes. nothing crucial
r32: *OverwriteExistingPackage isn't used anymore. one can delete it from ~/.config/pkgman/pkgman.conf.
*minor changes
version r33:
*"-l|--list" also shows installed package version and available ABS/AUR PKGBUILD version for given package.
*"-a|--abs" can now also be used with other options (like "-e")
r39: * when backing up src.tarballs it asks whether to backup the source file or not
* more detailed "--list" option - also shows if package is installed or not and available ABS/AUR version
* added prompt to clean up directory after makepkg
* when checking pkg.tar.gz also possibility to check for conflicts with files of already installed packages
* use $PAGER instead of less
* --help directly shows the manpage
* --shorthelp shows a brief usage overview
* added a custom prompt, but only when using bash (is somehow experimental - works fine here for me)
* minor internal changes
* pkgman also reads ~/.aurvote file for getting aur name and password. if one already uses aurvote then there is no need for the
~/.config/pkgman/AUR.conf file.
r40: * new manual page & rewrite of usage function
* both option "--flush" and "--flushall" were omitted in favor of the more versatile "--cleanup" option
* pkgman <packagename> checks now if <packagename> is owned by user
* backup option after each editing
* added license
* minor internal changes
r41: * just small bug fixes, nothing crucial.
r42: * more bugs fixed.
r45: * new options added:
> --listversions: list local and available versions of installed packages from LocalPackages directory
> --getownpackages: synchronize local own packages with AUR
* added new variable in pkgman.conf:
> ListOutputInPager: output of, for example, "--list" or "--own" is piped into $PAGER
* added a new optional dependency "desktop-file-utils" for validating desktop entry files
* also supports now auto-generation of sha sums not only md5
* internal fixes due to AUR interface changes:
> use of json interface
> correct parsing of package category
* added 2 proto files (located under /usr/share/pacman):
> proto.desktop: a template for *.desktop files
> PKGBUILD-lib32.proto: a template for lib32 packages for x86_64
* some code changes and fixes
r46: * added new option to pkgman.conf (AutoGenerateSums).
> if AutoGenerateSums=no then pkgman asks whether to generate checksums or not.
> if set to yes it behaves like in former versions.
r52: * "--getownpackages" with more than 100 packages works again
* added new option "--cachecopy":
For each package in CacheCopyList (new variable in pkgman.conf) get existing package from pacman's cache directory - if
CopyPkgFromCache (new variable in pkgman.conf) is set to yes - and/or create a source tarball of PKGBUILD and related files from ABS -
if CopySrcFromABS (new variable in pkgman.conf) is set to yes - and copy them to package backup directory.
* added new variables to pkgman.conf:
> "CacheCopyList=file" - batch backup file, one package per line - default location is "$HOME/.config/pkgman/package.list".
> "CopySrcFromABS=[yes|no]"
> "CopyPkgFromCache=[yes|no]"
* some bugfixes
* docs completed
* CacheCopyList should look like
package1
package2
#this is a comment
! this too
package3
!package4
r54: * renamed "--listversions" option to "--diffversions". makes more sense!
from the man page:
pkgman --diffversions
Show differing ABS/AUR versions of installed packages from LocalPackages.
r55: * minor changes.
r57: * testing release
* added a new option "--rollback":
"pkgman <packagename> --rollback" - checks http://arm.kh.nu for available package versions,
lets you choose one, fetches the package and
moves it to the <packagename> backup directory (if "--repoadd" is used).
r59: * stable release
* new option "--rollback" (see r57):
it checks http://arm.kh.nu (Arch Rollback Machine) for available package versions,
downloads chosen file and moves it to local repository (if "-r|--repoadd" is used).
* posting files/comments/etc to AUR should work now again.
r65: *stable release
* new option "-M,--meta" to create metapackages and add them and their dependencies to local repository.
it searches for deps inside the backup directories, pacman's cache and if the packages are not available, it tries to fetch the missing
dependencies from the Arch Rollback Machine site (http://arm.kh.nu).
r66: * minor fixes
r68: * some bugfixes
* "--repoadd" and "--Reporemove" now accurately removes old packages from LocalRepository
r69: * small bugfixes when listing packages with similar names
* curl retries now 5 times if connection is not established
r75: * "--cachecopy" does not try to dl sourcefiles when backing up ABS PKGBUILDs
* some work on package splitting
* further internal changes
r76: * minor mistakes with "ln" purged
r79: * mostly small changes
* "--cleanup" now also removes uninstalled packages from LocalRepository
r81 & r80: * added AUR v1.6.0 support (use more json)
* small ARM changes ("--rollback")
r85:
* pkgman supports pkg.tar.xz packages
* some code rewrite, bugs purged (hopefully)
r113:
* pkgman now supports building split packages through makepkg.
If you already use pkgman you need to rerun "pkgman --runmefirst" after updating.
* new "-t,--template" option ("pkgman <packagename> --template <alt. packagename> [--pkgbuildversion <version>] [options]").
Useful to create a new PKGBUILD and use an existing one as a template.
* new option: "--conf /path/to/alternate/conf/file" - Specify another configuration file.
* pkgman now uses ${XDG_CONFIG_HOME}/pkgman or $HOME/.config/pkgman - if first not set - as the default location for its conf files.
r116:
* check inet conection when submitting src tarballs to AUR
* some bugs
* updated manpage on sf
For further details please read the manual page.
Last edited by DonVla (2010-04-28 11:56:59)
I'm having some troubles with it (perhaps missing dependencies, and forgotten hardcoded dirs?):
jan@aconcagua 8:20PM ~ % pkgman --runmefirst
/usr/bin/pkgman: line 77: /home/jan/apps/skripte/archscripts/pkgman/share/pkgman/color.bash: No such file or directory
/usr/bin/pkgman: line 1293: initcolor: command not found
/usr/bin/pkgman: line 312: highlight: command not found
/usr/bin/pkgman: line 312: error: command not found
/usr/bin/pkgman: line 313: highlight: command not found
/usr/bin/pkgman: line 313: error: command not found
/usr/bin/pkgman: line 314: highlight: command not found
/usr/bin/pkgman: line 314: error: command not found
/usr/bin/pkgman: line 315: highlight: command not found
/usr/bin/pkgman: line 315: error: command not found
/usr/bin/pkgman: line 317: error: command not found
/usr/bin/pkgman: line 318: error: command not found
/usr/bin/pkgman: line 321: highlight: command not found
/usr/bin/pkgman: line 321: msg: command not found
/usr/bin/pkgman: line 329: list: command not found
/usr/bin/pkgman: line 332: list: command not found
/usr/bin/pkgman: line 332: list: command not found
touch: cannot touch `/bin/.pkgman.registered': Permission denied
/usr/bin/pkgman: line 332: list: command not found
/usr/bin/pkgman: line 332: list: command not found
/usr/bin/pkgman: line 332: list: command not found
/usr/bin/pkgman: line 332: list: command not found
/usr/bin/pkgman: line 332: list: command not found
/usr/bin/pkgman: line 337: msg: command not found
curl: option --output: requires parameter
curl: try 'curl --help' or 'curl --manual' for more information
^C/usr/bin/pkgman: line 209: cleanoutput: command not found
/usr/bin/pkgman: line 209: cleanoutput: command not found
(I terminated with ctrl-c).
EDIT: errors resolved by correcting the path $HOME/apps/skripte/archscripts/pkgman/share/pkgman to /usr/share/pkgman in the pkgman itself.
Last edited by bender02 (2008-05-23 01:28:58)
Similar Messages
-
"error while evaluating Java script for the package"
Okay, this is a new one on me! Anyone ever get this message? I don't know what is going on with my iMac, all I know is that about a month ago my iTunes was working fine, and when I just went to use it, it tells me "you can not use the application iTunes with this version of Mac OS X. So I thought maybe something was wrong with my iTunes and downloaded it again and i got the "error while evaluating Java script for the package" when I tried to reinstall iTunes. Another issue I am having is with updates. I haven't received an update for a long time and when I manually check, it tells me there are none.
Okay, this is a new one on me! Anyone ever get this message? I don't know what is going on with my iMac, all I know is that about a month ago my iTunes was working fine, and when I just went to use it, it tells me "you can not use the application iTunes with this version of Mac OS X. So I thought maybe something was wrong with my iTunes and downloaded it again and i got the "error while evaluating Java script for the package" when I tried to reinstall iTunes. Another issue I am having is with updates. I haven't received an update for a long time and when I manually check, it tells me there are none.
-
Need ant script to compile, package, and deploy to Oracle AS 10.3.1
I have a test app with ADF faces/jsf for front-end and EJB 3.0 Session Facade/Entity beans for back-end. The project structure/layout is similar to the SRDEMO app in JDeveloper. I was able to compile, package, and deploy within JDeveloper 10g to Oracle AS 10g successfully. Is there a sample ant script to compile, package, and deploy to Oracle AS 10g that I can run from command line? The build.xml that came with SRDEMO only do the compilation, not packaging and deployment. I was able to modify the SRDEMO's build.xml to compile my test app though. I still need the script to package and deploy it.
Thanks,Hi,
How are you referring to the class path. I have created my custom build file and I refer like this.
<path id="classpath">
<pathelement location="${oracle.home}/lib/aia.jar"/>
<pathelement location="${oracle.common.home}/modules/org.apache.commons.logging_1.0.4.jar"/>
</path> oracle.home is the location where my aia.jar resides.
In the compile-classes target I have
<!--Target for Class path details -->
<target name="compile-classes">
<mkdir dir="${sca-inf.classes.dir}"/>
<javac destdir="${sca-inf.classes.dir}" classpathref="classpath"
debug="on" nowarn="${javac.nowarn}"
deprecation="${javac.deprecation}" encoding="Cp1252"
source="1.6" target="1.6">
<src path="${src.dir}"/>
</javac>
</target> Regards,
Neeraj Sehgal -
[solved]Need help with a bash script for MOC conky artwork.
I need some help with a bash script for displaying artwork from MOC.
Music folders have a file called 'front.jpg' in them, so I need to pull the current directory from MOCP and then display the 'front.jpg' file in conky.
mocp -Q %file
gives me the current file playing, but I need the directory (perhaps some way to use only everything after the last '/'?)
A point in the right direction would be appreciated.
thanks, d
Last edited by dgz (2013-08-29 21:24:28)Xyne wrote:
You should also quote the variables and output in double quotes to make the code robust, e.g.
filename="$(mocp -Q %file)"
dirname="${filename%/*}"
cp "$dirname"/front.jpg ~/backup/art.jpg
Without the quotes, whitespace will break the code. Even if you don't expect whitespace in any of the paths, it's still good coding practice to include the quotes imo.
thanks for the tip.
here it is, anyhow:
#!/bin/bash
filename=$(mocp -Q %file)
dirname=${filename%/*}
cp ${dirname}/front.jpg ~/backup/art.jpg
then in conky:
$alignr${execi 30 ~/bin/artc}${image ~/backup/art.jpg -s 100x100 -p -3,60}
thanks for the help.
Last edited by dgz (2013-08-29 21:26:32) -
Start Of Ramp-Up for SAP Portfolio and Project Management 5.0
Start Of Ramp-Up for SAP Portfolio and Project Management 5.0
Starting with this new release, the application SAP Portfolio and Project Management 5.0
replaces both the SAP Resource and Portfolio Management (SAP RPM) application and the
Collaboration Projects (cProjects) application.
Start of ramp-up for SAP Portfolio and Project Management is 19th of April, 2010. The end
of ramp-up is currently scheduled for 19th of October, 2010.
Functional Innovations And New Features
A detailed description of all new and/or enhanced functional innovations and features can
be found in the Release Notes:
[http://service.sap.com/releasenotes |http://service.sap.com/releasenotes]
-> SAP Solutions
-> Release Notes SAP Portfolio and Project Management
There are some SAP Notes which are in general very important for SAP Portfolio and Project
Management 5.0 and which also serve as central points of entry to find import information:
SAP Note [1377104|https://service.sap.com/sap/support/notes/1377104] FAQs - SAP Portfolio and Project Management 5.0
SAP Note [1402912|https://service.sap.com/sap/support/notes/1402912] PPM 5.0: Supported Browsers, Java versions, etc.
SAP Note [1411953|https://service.sap.com/sap/support/notes/1411953] PPM 5.0: Configuration Content
SAP Note [1436778|https://service.sap.com/sap/support/notes/1436778] SAP Portfolio and Project Management 5.0: Restrictions
Kind regards,
FlorianThanks very much for taking the time to post the info Florian. I will update this thread as well if I run into any new information.
Do we have any idea on SAP's direction for Product Definition? PD is still version 2.0 and I heard that PD functionality will be incorporated into PPM 5.0 which does make a lot of sense. I very briefly went through the notes and config doc in this post and did not get the impression that PPM has any idea and concept management capabilities. -
Software for suspend/hibernate and power management?
After working with Arch on my desktop pc for a while, I today installed it on my laptop, as well. Everything works fine so far, but after reading through a lot of articles on the wiki and threads on this board, I'm a little confused about which tools I should use for hibernate/suspend and power management?
Cpufreq-utils, acpid, pm-utils, laptop-mode-tools, etc. What do you recommend for use?
Thanks in advance!
Last edited by mamr (2008-10-25 09:07:14)All that you listed there have different functions. I use all the above on my laptop. Cpufreq-utils enables the frequency scaling, pm-utils (should) enables suspend and/or hibernate, laptop-mode-tools adds some power management functions, etc. Anyways, they're all useful for a laptop. Install, tweak, ask questions
Good luck!
Scott -
Tables for Collection, dispute and credit management
Hi SAP Gurus,
I would appreciate if any one could provide the list of tables for collection, dispute and credit management. Thanks!
Regards,
ajI think you mean the tables for FSCM.
The easiest way to find it is to do SE16 FDM*
FDM_AR_WRITEOFFS FSCM-DM: Automatic Write-Offs Not Executed
FDM_BUFFER Cluster for Decoupling in 1-System Scenari
FDM_BW_INV_DELTA Delta Queue for BI Invoice Extractor
FDM_COLL_CCOLOAD Company Codes for which Initial Load Perfo
FDM_COLL_CFIELD FSCM-COL: Relevant Fields for Document Cha
FDM_COLL_COMPCOD FSCM-COL: Active Company Codes of Collecti
FDM_COLL_DUNNLEV Harmonized Dunning Levels
FDM_COLL_LASTPAY Last Payments of Business Partner
FDM_COLL_LTRIG Missing Entries of Table FDM_COLL_STRIG
FDM_COLL_SFIELD FSCM-COL: Relevant Fields for Document Cha
FDM_COLL_STRIG FSCM-COL: Control of Trigger Update in TRO
FDM_COLL_TROBJ FSCM-COL: Trigger Table for Collections Ma
FDM_CONTACT_BUF Personalization of Contact Person Data
FDM_DCOBJ FSCM-DM Integration: Disputed Objects
FDM_DCPROC FSCM-DM Integration: Dispute Case Processe
FDM_P2P_ATTR Attributes of Promise to Pay; Required for
FDM_PERSONALIZE Personalization of Collections Management
FDM1 Cash Management & Forecast: Line Items of
FDM2 Cash management line items from MM purchas
FDMV Cash Planning Line Items of Earmarked Fund
Hope this helps, award points if useful. -
Java scripting for header,footer and combine PDF as package
Hi All,
1.How to add header and footer using scripting.
2.How can i combine 5 pdf files in to one pdf as PDF file package using Java Scripting.
Thanks
Mohamed IdrisHi Lenonard,
Thanks for your reply, I am refering JavaScript for Acrobat API Reference, Version 8 document , but i could not find the right syntax for the above task.
I am sucessfull writing script for page label but not for insertion of page number in the footer section.
Regarding combining PDF files i could merge file and it comes as single PDF file not like assembeling pdf files as package.
Please let me know the syntax and if i am looking at not right documentation, please let me know the document name to refer.
Thanks again.
Mohamed Idris -
Script for downloading(svn) and install E17
I've been working on a script that download for the svn repository e17, compiler and install. I've made this script more as a to lear more about bash script. You can do the same thing as my script with yaourt. I hope someone might need it.
#!/bin/bash
# Title: Arch E17 svn #
# Auther: Kamil MIklaszewski ([email protected]) #
# Date: 2008-12-19 19:10 #
# Licence: GPL #
# This program is free software; you can redistribute it and/or modify #
# it under the terms of the GNU General Public License as published by #
# the Free Software Foundation; either version 2 of the License, or #
# (at your option) any later version. #
# This program is distributed in the hope that it will be useful, #
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
# GNU General Public License for more details. #
# You should have received a copy of the GNU General Public License #
# along with this program; if not, write to the Free Software #
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, #
# MA 02110-1301, USA. #
# Version: 1.0 #
# Description: This script was writen for Archlinux. It will download e17 #
# from the svn repository and it will do a full installation. #
# This script also take care of the dependency for all of the #
# programs that are installed with e17. #
# TODO: For version 1.0 #
# -have the scipt use dialog #
# -make the script more autamatic #
# Change Log: *2008-12-19 #
# -creation of script #
# Function name: prep
# Function paramiter(s): none
# Function description: This function prepers the envirement to run
# the rest of the script
prep()
#make a temporery directory and go to it
mkdir -p ~/arch_e17_svn
cd ~/arch_e17_svn
#export this path to compile succesfuly
export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig/
# Function name: message
# Function paramiter(s): Word to be printed on the screen
# Function description: This function print messages on the screen.
message()
#print a message to the screen
echo -e "==>" $*
# Function name: downloadPackage
# Function paramiter(s): none
# Function description: This function go to the user's home
# directory and downloads e17 from svn repo.
downloadPackage()
message "Downloading " $1 " from E17 svn repository."
#download the specifed package with less text
svn co --quiet http://svn.enlightenment.org/svn/e/trunk/$1 $1-svn
# Function name: generalDependencys
# Function paramiter(s): none
# Function description: This fuction install the general
# dependencys.
generalDependencys()
message "Installing Dependencys..."
#list of package needed to be installed
generalDependencysList=(
'svn'
'm4'
'autoconf'
'automake'
'libtool'
'pkgconfig'
'texinfo'
'zlib'
'libpng'
'libjpeg'
'freetype2'
'xorg'
'dbus'
'hal'
'pam'
'librsvg'
'libnotify'
'curl'
'openssl'
'libungif'
'libtiff'
'gettext'
'glibc'
'glibmm'
'doxygen'
'giflib'
'cairo'
'libx11'
'libxext'
'libxrender'
'fontconfig'
'libxcb'
'sdl'
'mesa'
'qt'
'librsvg'
'libtiff'
'directfb'
#install the dependencys in the list
sudo pacman -Sq --needed ${generalDependencysList[@]}
# Function name: installPackage
# Function paramiter(s): The name of the package to install
# Function description: This fuction need one paramiter that is
# the package to configure and install.
installPackage()
#change directory to the program to configure and install
cd ~/arch_e17_svn/$1-svn
message "Configurating package " $1
#run the autogen script that will configure and
#make read to install this program
./autogen.sh
message "Compiling package " $1
#now compile the source file of the program
make
message "Installing package " $1
#now install the program
sudo make install
cleanUp()
rm -r ~/arch_e17_svn
# MAIN #
main()
#preper the envirement
prep
#install the general dependecys using pacman
generalDependencys
#list of packages to download and install
packagesList=(
'eina'
'eet'
'evas'
'ecore'
'efreet'
'embryo'
'edje'
'e_dbus'
'e'
#loop that gos through the list and downloads the packages
for package in ${packagesList[@]}
do
downloadPackage $package
message "Done\n"
done
#loop that gos through the list and installs the packages
for package in ${packagesList[@]}
do
installPackage $package
message "Done\n"
done
mainpressh wrote:to not duplicate work I've already created a python script some time ago which you can use to build e17 pacman packages using the community PKGBUILDs: http://dev.archlinux.org/~ronald/e17.html
I may extend its usage if someone sees any use for it. Either way, just thought I should drop it here.
is that script any different from a full build through makepkg/yaourt using AUR's Pkgbuilds?
I tried to use it but i get a list of errors similar to
cp: impossibile creare il file normale `eina-build/eina/.svn/prop-base/NEWS.svn-
base': Permission denied
but if i can use yaourt, why not?
Edit: sorry, i looked at the python source and realized that it actually just syncs abs and then runs makepkg and namcap for each package. so i guess i'll use yaourt instead (or try to understand why makepkg exits with that error)
Last edited by pikiweb (2009-06-19 08:48:46) -
Udev bash script for autodialing usb huawei modem
Hey
I've got an interesting one here.
I have scripted up a bash script to be triggered by a udev add event for my usb modem. As far as I can tell the udev event is firing correctly according to udevadm.
ACTION=="add", ATTRS{idVendor}=="12d1", ATTRS{idProduct}=="1003", RUN+="/bin/sh /usr/local/bin/huawei_key.sh add"
ACTION=="remove", ATTRS{idVendor}=="12d1", ATTRS{idProduct}=="1003", RUN+="/bin/sh /usr/local/bin/huawei_key.sh remove"
And heres the code from the script
#!/bin/bash
#returns
# 0 Successfully ran script for case
# 1 wvdial process already running
# 2 wvdial was not terminated
# 3 script was not ran with ADD or REMOVE events
function getpid #get process id of running program
pidof wvdial
if [ "$?" = 0 ];
then
pid=`pidof wvdial`
running=1
else
running=0
fi
function checkrun #check for a running copy of the program
pidof wvdial
if [ "$?" == "0" ];
then
running=1
else
running=0
fi
function killloop #a set of time kill commands to let the program exit gracefully
#two terms, one int and one kill with suitable gaps
getpid
checkrun
if [ "$running" = "0" ];
then
return
fi
kill $pid
sleep 10
checkrun
if [ "$running" = "0" ];
then
return
fi
kill $pid
sleep 10
checkrun
if [ "$running" = "0" ];
then
return
fi
kill -INT $pid
sleep 5
checkrun
if [ "$running" = "0" ];
then
return
fi
kill -KILL $pid
sleep 5
checkrun
if [ "$running" = "1" ];
then
exit 2 #process fails to die
fi
function getlaststatus
if [ -e "/var/run/huawie" ];
then
last=`cat /var/run/huawie`
else
last=0
fi
if [ "$1" = "add" ];
then
getlaststatus
if [ "$last" = "1" ];
then
exit 1
fi
echo 1 > /var/run/huawie #block future udev events
getpid
if [ "$running" = "1" ];
then
exit 1
fi
modprobe usbserial
sleep 6 #modem init time
wvdial &
exit 0
elif [ "$1" = "remove" ];
then
getlaststatus
if [ "$last" = "2" ];
then
exit 0
fi
echo 2 > /var/run/huawie
killloop
exit 0
else
echo 3 > /var/run/huawie
exit 3
fi
I'd appreciate any ideas, this one has me stumped
Edit:
Forgot to add that when I call the script manually it works like a charm.
Last edited by adamd (2009-08-25 15:04:06)Hey
I've got an interesting one here.
I have scripted up a bash script to be triggered by a udev add event for my usb modem. As far as I can tell the udev event is firing correctly according to udevadm.
ACTION=="add", ATTRS{idVendor}=="12d1", ATTRS{idProduct}=="1003", RUN+="/bin/sh /usr/local/bin/huawei_key.sh add"
ACTION=="remove", ATTRS{idVendor}=="12d1", ATTRS{idProduct}=="1003", RUN+="/bin/sh /usr/local/bin/huawei_key.sh remove"
And heres the code from the script
#!/bin/bash
#returns
# 0 Successfully ran script for case
# 1 wvdial process already running
# 2 wvdial was not terminated
# 3 script was not ran with ADD or REMOVE events
function getpid #get process id of running program
pidof wvdial
if [ "$?" = 0 ];
then
pid=`pidof wvdial`
running=1
else
running=0
fi
function checkrun #check for a running copy of the program
pidof wvdial
if [ "$?" == "0" ];
then
running=1
else
running=0
fi
function killloop #a set of time kill commands to let the program exit gracefully
#two terms, one int and one kill with suitable gaps
getpid
checkrun
if [ "$running" = "0" ];
then
return
fi
kill $pid
sleep 10
checkrun
if [ "$running" = "0" ];
then
return
fi
kill $pid
sleep 10
checkrun
if [ "$running" = "0" ];
then
return
fi
kill -INT $pid
sleep 5
checkrun
if [ "$running" = "0" ];
then
return
fi
kill -KILL $pid
sleep 5
checkrun
if [ "$running" = "1" ];
then
exit 2 #process fails to die
fi
function getlaststatus
if [ -e "/var/run/huawie" ];
then
last=`cat /var/run/huawie`
else
last=0
fi
if [ "$1" = "add" ];
then
getlaststatus
if [ "$last" = "1" ];
then
exit 1
fi
echo 1 > /var/run/huawie #block future udev events
getpid
if [ "$running" = "1" ];
then
exit 1
fi
modprobe usbserial
sleep 6 #modem init time
wvdial &
exit 0
elif [ "$1" = "remove" ];
then
getlaststatus
if [ "$last" = "2" ];
then
exit 0
fi
echo 2 > /var/run/huawie
killloop
exit 0
else
echo 3 > /var/run/huawie
exit 3
fi
I'd appreciate any ideas, this one has me stumped
Edit:
Forgot to add that when I call the script manually it works like a charm.
Last edited by adamd (2009-08-25 15:04:06) -
Bash script for checking link status
So I'm doing some SEO work I've been tasked with checking a couple hundred thousand back links for quality. I found myself spending a lot of time navigating to sites that no longer existed. I figured I would make a bash script that checks if the links are active first. The problem is my script is slower than evolution. I'm no bash guru or anything so I figured maybe I would see if there are some optimizations you folks can think of. Here is what I am working with:
#!/bin/bash
while read line
do
#pull page source and grep for domain
curl -s "$line" | grep "example.com"
if [[ $? -eq 0 ]]
then
echo \"$line\",\"link active\" >> csv.csv else
echo \"$line\",\"REMOVED\" >> csv.csv
fi
done < <(cat links.txt)
Can you guys think of another way of doing this that might be quicker? I realize the bottleneck is curl (as well as the speed of the remote server/dns servers) and that there isn't really a way around that. Is there another tool or technique I could use within my script to speed up this process?
I will still have to go through the active links one by one and analyze by hand but I don't think there is a good way of doing this programmatically that wouldn't consume more time than doing it by hand (if it's even possible).
ThanksI know it's been awhile but I've found myself in need of this yet again. I've modified Xyne's script a little to work a little more consistently with my data. The problem I'm running into now is that urllib doesn't accept IRIs. No surprise there I suppose as it's urllib and not irilib. Does anyone know of any libraries that will convert an IRI to a URI? Here is the code I am working with:
#!/usr/bin/env python3
from threading import Thread
from queue import Queue
from urllib.request import Request, urlopen
from urllib.error import URLError
import csv
import sys
import argparse
parser = argparse.ArgumentParser(description='Check list of URLs for existence of link in html')
parser.add_argument('-d','--domain', help='The domain you would like to search for a link to', required=True)
parser.add_argument('-i','--input', help='Text file with list of URLs to check', required=True)
parser.add_argument('-o','--output', help='Named of csv to output results to', required=True)
parser.add_argument('-v','--verbose', help='Display URLs and statuses in the terminal', required=False, action='store_true')
ARGS = vars(parser.parse_args())
INFILE = ARGS['input']
OUTFILE = ARGS['output']
DOMAIN = ARGS['domain']
REMOVED = 'REMOVED'
EXISTS = 'EXISTS'
NUMBER_OF_WORKERS = 50
#Workers
def worker(input_queue, output_queue):
while True:
url = input_queue.get()
if url is None:
input_queue.task_done()
input_queue.put(None)
break
request = Request(url)
try:
response = urlopen(request)
html = str(response.read())
if DOMAIN in html:
status = EXISTS
else:
status = REMOVED
except URLError:
status = REMOVED
output_queue.put((url, status))
input_queue.task_done()
#Queues
input_queue = Queue()
output_queue = Queue()
#Create threads
for i in range(NUMBER_OF_WORKERS):
t = Thread(target=worker, args=(input_queue, output_queue))
t.daemon = True
t.start()
#Populate input queue
number_of_urls = 0
with open(INFILE, 'r') as f:
for line in f:
input_queue.put(line.strip())
number_of_urls += 1
input_queue.put(None)
#Write URL and Status to csv file
with open(OUTFILE, 'a') as f:
c = csv.writer(f, delimiter=',', quotechar='"')
for i in range(number_of_urls):
url, status = output_queue.get()
if ARGS['verbose']:
print('{}\n {}'.format(url, status))
c.writerow((url, status))
output_queue.task_done()
input_queue.get()
input_queue.task_done()
input_queue.join()
output_queue.join()
The problem seems to be when I use urlopen
response = urlopen(request)
with a URL like http://www.rafo.co.il/בר-פאלי-p1
urlopen fails with an error like this:
Exception in thread Thread-19:
Traceback (most recent call last):
File "/usr/local/Cellar/python3/3.3.0/Frameworks/Python.framework/Versions/3.3/lib/python3.3/threading.py", line 639, in _bootstrap_inner
self.run()
File "/usr/local/Cellar/python3/3.3.0/Frameworks/Python.framework/Versions/3.3/lib/python3.3/threading.py", line 596, in run
self._target(*self._args, **self._kwargs)
File "./linkcheck.py", line 35, in worker
response = urlopen(request)
File "/usr/local/Cellar/python3/3.3.0/Frameworks/Python.framework/Versions/3.3/lib/python3.3/urllib/request.py", line 160, in urlopen
return opener.open(url, data, timeout)
File "/usr/local/Cellar/python3/3.3.0/Frameworks/Python.framework/Versions/3.3/lib/python3.3/urllib/request.py", line 473, in open
response = self._open(req, data)
File "/usr/local/Cellar/python3/3.3.0/Frameworks/Python.framework/Versions/3.3/lib/python3.3/urllib/request.py", line 491, in _open
'_open', req)
File "/usr/local/Cellar/python3/3.3.0/Frameworks/Python.framework/Versions/3.3/lib/python3.3/urllib/request.py", line 451, in _call_chain
result = func(*args)
File "/usr/local/Cellar/python3/3.3.0/Frameworks/Python.framework/Versions/3.3/lib/python3.3/urllib/request.py", line 1272, in http_open
return self.do_open(http.client.HTTPConnection, req)
File "/usr/local/Cellar/python3/3.3.0/Frameworks/Python.framework/Versions/3.3/lib/python3.3/urllib/request.py", line 1252, in do_open
h.request(req.get_method(), req.selector, req.data, headers)
File "/usr/local/Cellar/python3/3.3.0/Frameworks/Python.framework/Versions/3.3/lib/python3.3/http/client.py", line 1049, in request
self._send_request(method, url, body, headers)
File "/usr/local/Cellar/python3/3.3.0/Frameworks/Python.framework/Versions/3.3/lib/python3.3/http/client.py", line 1077, in _send_request
self.putrequest(method, url, **skips)
File "/usr/local/Cellar/python3/3.3.0/Frameworks/Python.framework/Versions/3.3/lib/python3.3/http/client.py", line 941, in putrequest
self._output(request.encode('ascii'))
UnicodeEncodeError: 'ascii' codec can't encode characters in position 5-8: ordinal not in range(128)
I'm not too familiar with how character encoding works so I'm not sure where to start. What would be a quick and dirty way (if one exists) to get URLs like this to play nicely with python's urlopen? -
Bash script for apache restart
I need a way of restarting apache for a user who does not have admin priveleges. My thought is that a bash script could be written to restart apache and would also have the admin password. The permissions would be such that the non-admin user could execute it but not read/write.
i.e.
sudo apachectl restart
??password??
I don't know if this is possible because sudo has -p but I didn't see --password
Mini Mac OS X (10.4.8)Hi David,
I've posted about sudo on two threads that are still on page one, Startup permissions change and system.log question. You shouldn't need a password and you can specify exactly who should be able to restart Apache.
You probably think of sudo as an all-or-nothing solution; either a user can execute anything as root or nothing. Nothing could be closer to the truth. Not only can you specify individual commands but you can specify arguments as well. Thus, you could give someone the right to start or restart Apache but not to stop it. The perfect solution has been created for you; give it a whirl.
Gary
~~~~
... an anecdote from IBM's Yorktown Heights Research Center. When a programmer used his new computer terminal, all was fine when he was sitting down, but he couldn't log in to the system when he was standing up. That behavior was 100 percent repeatable: he could always log in when sitting and never when standing.
Most of us just sit back and marvel at such a story; how could that terminal know whether the poor guy was sitting or standing? Good debuggers, though, know that there has to be a reason. Electrical theories are the easiest to hypothesize: was there a loose wire under the carpet, or problems with static electricity? But electrical problems are rarely consistently reproducible. An alert IBMer finally noticed that the problem was in the terminal's keyboard: the tops of two keys were switched. When the programmer was seated he was a touch typist and the problem went unnoticed, but when he stood he was led astray by hunting and pecking.
-- "Programming Pearls" column, by Jon Bentley in CACM February 1985 -
Helpful Linux Bash Scripts for I.T. Admins
I was wondering if you guys had any recommendations for helpful / simple Bash scripts that do helpful tasks in regards to Linux system administration? I have never created or used a Bash shell script but know that many of you guys do. I have no programming experience what so ever so decided to ask if you guys do have one or few scripts that are useful in basic administration tasks, could you please post them or at least point someone who is interested in the right direction?
Thank you so much!I'm no sysadmin but one were to use command-line a lot i would give ZSH a shot. A nicely configured zsh shell can be unbelievably comfortable and is certainly a great tool.
As for scripts I always thought of them as little helpers customized for certain situations. For instance easing repetitive tasks, batching some steps and timing/automating little things. For general purpose I'd probably look at available software first.
Maybe tmux for terminal management, ranger for file management, a tiling window manager for efficiency, ssh and other survaillance/maintenance software? Personally, I'd very much like to hear, too, what software/scripts/.. linux systems admins use to keep the work to a minimum . -
SAP Scripts for Stock Removal and Stock Placement ?
Hi All,
Can you please let me know what are the SAP script names and Transaction codes for Stock Removal and Stock Placements ?
Thanks,
RajHi
Tcode is MIGO only (select Goods receipt) and mvt type as
Putaway (305, 315, and so on)
Stock removal (303, 313, and so on)
Transfer posting (301, 311, and so on)
regards
Yogesh -
Powershell script for security groups and users for multiple share folders
Hi scripting team,
I need your help with powershell script for the below queries
1. List out the security groups for more than one server share path and output it to a file ( csv )
For eg.
If the are are two share paths
\\servername\foldermain\folder1
\\servername\foldermain\folder2
So I needs the list of security groups for each share path
And the output needs to be under each any every path.
2. Grab the users belongs to main security groups and it nested groups for more than one security group and listed the users under each and every group. No need to display nested groups. Just users belongs to main group and users under nested.
Your teams help is much appreciated
Thank you.
Thilochana kumararatneHi Braham,
Thanks for your quick reply.
Are we able to do this on two stage method
1. grab the security groups from the share paths
if can grab the share path from a separate txt file than copying it to the <your path> location
so i can modify the txt file
once run the script
if can the output like below to a CSV file
\\servername\foldermain\folder1group 1group 2group 3\\servername\foldermain\folder2group 1group 2group 3then i know which groups belongs to which share paththen i can remove the duplicate groups and keep the common groups to grab the users belongs to itso with the second script same as the first copy the security groups to a txt file and the out put as below.what I needs is the users full name and the samaccount name ( user id )group 1user1user2user3
group 2user1user2user3looking forward your help on thisThank you.Thilo
Maybe you are looking for
-
SPAM error while applying ABAP patch 13
Hi all, I was applying patches on neweaver system Windows oracle platform. All patches till now successfully applied except patch 13 for ABAP and now situation is spam is running from alomost 24 Hrs and i have also tried to restart the same but all
-
Positioning a vertical line in Pages document??
I have a Pages word processing document that has three columns (like a classified ad page in a newspaper). I want to add vertical lines between the columns but I want to center and position the vertical lines myself between the columns. What setting
-
Selections & Levels Adjustment Layer Not Working Properly
Hello, I'm experiencing something that I've never encountered before. I've used the selection function and levels adjustment layer hundreds of times and I've never ever seen this... When I make a selection (in this case the signatures on the attache
-
Code completion for fl.* group?
hey, i'm not getting code completion for tweens or anything like that. when i type 'import fl.' i also don't get any completion. what am i missing? how do i fix it? thnx for the help. lou
-
Firefox not warn of closing multiple tabs.
Even though my settings have it checked off as "Warn me when closing multiple tabs." it doesn't do so. This becomes an issue when i accidentally click the X when dragging the slider up when when I'm trying to find my mouse pointer.